Skip to content

Instantly share code, notes, and snippets.

@serialhex
Created April 19, 2011 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serialhex/926844 to your computer and use it in GitHub Desktop.
Save serialhex/926844 to your computer and use it in GitHub Desktop.
learn the measure of a thing if it can only be measured in prime numbers...
#!/usr/bin/env ruby
require 'prime'
def nth_prime(n)
pr = Prime.new
t = 0
n.times do
t = pr.next
end
return t
end
class MeasureMe
def initialize( size )
@size = size
end
def measure
t = 0
pr = n = 1
while t < @size
pr = nth_prime(pr)
t += 1
n += 1
end
return pr
end
end
if __FILE__ == $PROGRAM_NAME # only run the following if it's running by itself
justin = MeasureMe.new( nth_prime(1) * nth_prime(nth_prime(1)) )
puts justin.measure
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment