[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[oneliners] prime genrator in 34 bytes

Simon Strandgaard

3/24/2005 2:55:00 AM

The previous record seen on http://rubygarden.org/ruby...
seems to to have been 46 bytes (its unclear who the author was).


JIX proposed this 34 bytes long solution.
i=l=1;(l%i+=1)>i-2&&p(i)while l*=i

Congratulations Jix, it was entertaining me and flgr.


I proposed a 40 bytes solution that isn't endless:
l=1;2.upto(1000){|i|p i if l%i>i-2;l*=i}

--
Simon Strandgaard