Created
April 19, 2011 04:58
-
-
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...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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