require 'mathn'

print "How many prime numbers do you want? "
wanted_amount = gets.to_i
print "The starting prime should be bigger than which number? "
startnum = gets.to_i
puts "______________________________________";
puts "Here are your primes:";

primenumbers = Prime.new()
current_amount=0;
primenumbers.each{|prime|
if prime >= startnum
puts prime
current_amount=current_amount+1
end
break unless current_amount < wanted_amount
}
puts “-—————————————————-”;

“break unless”; … mhhh… ruby has nice control structures :)

Comments