Re:Corecursion
by nodejsguy on Thursday May 08, 2014 @11:32PM
(#7719177)
If this was reddit, you would get gold for that reply
[ Parent
| on HN ]
Re:Corecursion
by gamegoblin on Friday May 09, 2014 @12:11AM
(#7719311)
In the time it took me to do it by hand I am 100% positive I could have written a Python program to do it probably 3 times.
Yyyyep just tested it:
def fibs(n, tabs=0):
if n < 2:
print "\t"*tabs + "1"
return 1
print "\t"*tabs+"fibs %d"%n
a = fibs(n-1, tabs+1)
b = fibs(n-2, tabs+1)
print "\t"*tabs+str(a+b)
return a+b
Took exactly 71 seconds to write. I probably spent 3 minutes on it by hand getting all the spaces right.