From: Roelof Wobben Date: 2012-10-01T01:55:42+09:00 Subject: Re: prime numbers problem --_f0c71665-785e-409d-b052-bc925ca1ac86_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks it worked now and I solved the problem. Roelof > Date: Mon=2C 1 Oct 2012 00:54:05 +0900 > From: stefano.crocco@alice.it > Subject: Re: prime numbers problem > To: ruby-talk@ruby-lang.org >=20 > On Monday 01 October 2012 Roelof Wobben wrote > > Hello=2C > >=20 > > I found out that ruby 1.9 has a prime class. > > So I tried this : list_primes.each { |prime| print prime=2C " "=3B brea= k unless > > prime < 90 } > >=20 > > 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 > >=20 > > That looks no good because 97 is more then 90. > >=20 > > How can this be happen ? > >=20 > > Roelof >=20 > Well=2C you're telling ruby to break the loop after having printed out th= e=20 > number=2C so of course it'll print 97=2C then break the loop. You'll need= to=20 > reverse the order of the expressions inside the block to achieve what you= =20 > want. >=20 > Stefano >=20 = --_f0c71665-785e-409d-b052-bc925ca1ac86_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thanks it worked now =3Band =3BI solved the problem.
 =3BRoelof

 =3B
>= =3B Date: Mon=2C 1 Oct 2012 00:54:05 +0900
>=3B From: stefano.crocco@a= lice.it
>=3B Subject: Re: prime numbers problem
>=3B To: ruby-tal= k@ruby-lang.org
>=3B
>=3B On Monday 01 October 2012 Roelof Wobbe= n wrote
>=3B >=3B Hello=2C
>=3B >=3B
>=3B >=3B I fou= nd out that ruby 1.9 has a prime class.
>=3B >=3B So I tried this : = list_primes.each { |prime| print prime=2C " "=3B break unless
>=3B >= =3B prime <=3B 90 }
>=3B >=3B
>=3B >=3B And I get this ans= wer : 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67
>=3B >=3B= 71 73 79 83 89 97
>=3B >=3B
>=3B >=3B That looks no good be= cause 97 is more then 90.
>=3B >=3B
>=3B >=3B How can this b= e happen ?
>=3B >=3B
>=3B >=3B Roelof
>=3B
>=3B W= ell=2C you're telling ruby to break the loop after having printed out the <= br>>=3B number=2C so of course it'll print 97=2C then break the loop. You= 'll need to
>=3B reverse the order of the expressions inside the bloc= k to achieve what you
>=3B want.
>=3B
>=3B Stefano
>= =3B
= --_f0c71665-785e-409d-b052-bc925ca1ac86_--