piranha gtv test cat fac rb def fac if else fac i-1 end end 1000 times

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
piranha@gtv ~/test>cat fac.rb
def fac i
if i == 1
i
else
i * fac(i-1)
end
end
1000.times { fac 200 }
piranha@gtv ~/test>cat fac.py
def fac(i):
if i == 1:
return i
return i * fac(i-1)
for i in xrange(1000):
fac(200)
piranha@gtv ~/test>time ruby fac.rb
ruby fac.rb 0.42s user 0.03s system 99% cpu 0.452 total
piranha@gtv ~/test>time ruby1.9 fac.rb
ruby1.9 fac.rb 0.29s user 0.00s system 96% cpu 0.302 total
piranha@gtv ~/test>time python fac.py
python fac.py 0.10s user 0.01s system 100% cpu 0.111 total