Mercurial > op > Looping
view Looping.rb @ 10:308cc64c24b9 >>178
Goのソースコードを追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Thu, 24 Feb 2011 07:31:17 +0900 |
parents | 30da8c1da4d4 |
children |
line wrap: on
line source
#!/usr/bin/env ruby class Looping def initialize() @n0 = 0 end def calc(n) n1 = @n0 + (1 - 2*(n%2)) @n0 = n n1 end end if __FILE__ == $0 s = Looping.new c = 0 n = 1 t1 = Time.now while c<2147483647 n = s.calc(n) c+=1 end t2 = Time.now puts "#{n} Ruby\t#{t2-t1}" end