+ 2
Factorial
https://code.sololearn.com/cqMK0HnC1FgF/?ref=app I coded a function that calls itself; Basically it gets the factorial of any number, but when the number is bigger than 100 it gets returned as if itâs factorial is equal to 0. However this only happens when you define the function as an integer. Why does it happen?
2 Answers
+ 6
If I understand what you're saying, you can't input a decimal number (2.4, 3.1, etc.) because the condition to end the recursive function requires that the value eventually equals 1 by subtracting 1 to it repeatedly. Because you cannot subtract decimal numbers by 1 to reach 1, it will never actually exit the loop and therefore create an infinite loop
+ 4
Using your program I got 200! = 7.88658e+374 so it seems to work for integers larger than 100. Also tested and works for 1500!