[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Intensive computing: Ruby? Ruby/C? Pure C++?
From:       "William James" <w_a_x_man () yahoo ! com>
Date:       2007-01-18 17:45:08
Message-ID: 1169142015.462631.63700 () 38g2000cwa ! googlegroups ! com
[Download RAW message or body]

William James wrote:

>
> print(prime(2))
> print(prime(4))
> print(prime(7))
> print(prime(25))
> print('----- the rest are primes')
> time = os.clock()
> print(prime(1073676287))
> print(prime(68718952447))
> print(prime(87178291199))
> print(prime(274877906899))
> print(prime(549755813881))
> print(prime(1099511627689))
> print(prime(2199023255531))
> print(prime(4398046511093))
> print(prime(8796093022151))
> print(prime(17592186044399))
> print(prime(953467954114363))
> print(os.clock() - time)

A little less crude:

function report_primality( tbl )
  for _, n in ipairs( tbl ) do
    print( prime( n ) )
  end
end

report_primality( { 2, 4, 7, 25 } )

print( '----- the rest are primes' )
time = os.clock()

report_primality( {
  1073676287,
  68718952447,
  87178291199,
  274877906899,
  549755813881,
  1099511627689,
  2199023255531,
  4398046511093,
  8796093022151,
  17592186044399,
  953467954114363   } )

print(os.clock() - time)


Ruby    87.781 seconds
Lua      4.188 seconds
LuaJIT   0.718 seconds


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic