Mercurial > op > Looping
view Looping.rb @ 12:dab1e83799e4 >>178 tip
R版のソースコードを追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Sat, 04 Feb 2012 04:10:01 +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