0

When I try to calculate something like 599! in Matlab, the answer is inf and not useful, but I am able to do that fine in python in google collab. Even when I try using stirling approximation for these large factorials I still get inf as an answer and I can't do anything with that (I'm trying to calculate multiplicity).

Why is it this way, especially since google collab isn't even on my computer its in the cloud or whatever. Can someone explain how this is possible?

1
  • Integers in Python 3 have unlimited precision. Commented Jun 2, 2021 at 22:14

1 Answer 1

1

Very simply, MATLAB has a hard limit on the size of integers and floats, and returns inf when you pass that value. Python implements a long-integer mode, an unlimited digital mode for computation. When you pass the "normal" 64-bit limit, Python converts to that long integer mode and continues operation -- at a very reduced speed.

Sign up to request clarification or add additional context in comments.

2 Comments

MATLAB doesn't even use integers unless you tell it to.
Right; I presumed integer specification due to the nature of the problem and OP's integer notation. I added float to the answer; thanks. The principle still applies.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.