lastPrime2011.rb
def isPrime(n)
2.upto(Math.sqrt(n).to_i) {|i|
if n%i==0
return false
end
}
return true
end
20111213.upto(20111231) do |i|
if isPrime(i)
puts i
end
end
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
def isPrime(n)
2.upto(Math.sqrt(n).to_i) {|i|
if n%i==0
return false
end
}
return true
end
20111213.upto(20111231) do |i|
if isPrime(i)
puts i
end
end
Register as a new user and use Qiita more conveniently
Go to list of users who liked