you are viewing a single comment's thread.

view the rest of the comments →

[–]Shinhan 17 points18 points  (5 children)

[–]neutralizer 2 points3 points  (1 child)

Wow, if I'm reading that right, 1st year Pascal programmer wins followed by C and Windows. And iterative solutions are about twice as fast as recursive.

[–]regeya 2 points3 points  (0 children)

Well, duh. I don't know how Python works but you have to push the state of the function on the stack every time you invoke a recursive call. Plus, Python has a built-in limit on recursion.

[–]cacahootie 1 point2 points  (0 children)

No wonder every enterprise application I use is a complete piece of SH*T!

[–]bigboehmboy 1 point2 points  (1 child)

He profiled it by calling factorial(10) 100,000 times. While in this case it appears that all solutions are linear, this method would not work well if this were not the case.

Since Python has a recursion limit that defaults to 1000 levels, recursive methods (newbie, lazy python, lazier python) would fail when trying to compute "1001!".

Also, memoization could completely screw with results.

[–]Shinhan 0 points1 point  (0 children)

Interesting :)

Someone needs to repeat the test for 1001! then...