- 150 名前:デフォルトの名無しさん [2007/12/01(土) 18:51:41 .net]
- Pythonオワタ・・・orz
俺もう乗り換えるわ Running the snippets above, I got the following results: Python 2.5.1: 31.507s Ruby 1.9.0: 11.934s The Ruby code: def fib(n) if n == 0 || n == 1 n else fib(n-1) + fib(n-2) end end 36.times do |i| puts "n=#{i} => #{fib(i)}" end And the Python equivalent: def fib(n): if n == 0 or n == 1: return n else: return fib(n-1) + fib(n-2) for i in range(36): print "n=%d => %d" % (i, fib(i))
|
|