Can anyone fix my code so it works? Python 2 http://ideone.com/xLsnH
works fine for smaller numbers
That's the problem with recursive functions. O(n) algorithms also use O(n) stack frames, so they'll only work for small numbers. http://ideone.com/OrOSi I guess python has a 1000-frame limit. But how cool is it that it calculated 999! in 20ms?
http://ideone.com/rtvSJ http://docs.python.org/library/sys.html#sys.getrecursionlimit http://docs.python.org/library/sys.html#sys.setrecursionlimit
I was able to get up to 21000! with bwCA's iterative version before ideone timed out. Over 81k digits!
I think that's a limitation of ideone. SIGXFSZ means the process exceeded some maximum file size. I don't know exactly what that means, but it does return a number, but the number is missing a great many 0's at the end, so it must have been truncated. Maybe ideone also has a limit on the amount of output it will return to the http client.
Join our real-time social learning platform and learn together with your friends!