From: Stefano Crocco Date: 2012-10-01T00:54:05+09:00 Subject: Re: prime numbers problem On Monday 01 October 2012 Roelof Wobben wrote > Hello, > > I found out that ruby 1.9 has a prime class. > So I tried this : list_primes.each { |prime| print prime, " "; break unless > prime < 90 } > > And I get this answer : 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 > 71 73 79 83 89 97 > > That looks no good because 97 is more then 90. > > How can this be happen ? > > Roelof Well, you're telling ruby to break the loop after having printed out the number, so of course it'll print 97, then break the loop. You'll need to reverse the order of the expressions inside the block to achieve what you want. Stefano