Sha256: d8b93a97afcae9a39d2842e02b9bf40ac490346f4adf28e7da6396f59cd5a035
Contents?: true
Size: 469 Bytes
Versions: 46
Compression:
Stored size: 469 Bytes
Contents
begin require 'rubygems' rescue LoadError end require 'inline' class FastMath def factorial(n) f = 1 n.downto(2) { |x| f *= x } return f end inline do |builder| builder.c " long factorial_c(int max) { int i=max, result=1; while (i >= 2) { result *= i--; } return result; }" end end math = FastMath.new if ARGV.empty? then 30000.times do math.factorial(20); end else 30000.times do math.factorial_c(20); end end
Version data entries
46 entries across 46 versions & 4 rubygems