pythonがこの先生きの ..
150:デフォルトの名無しさん
07/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))
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
3260日前に更新/149 KB
担当:undef