r/codegolf • u/binarycat64 • Oct 16 '20
Prime numbers in 63 bytes of ruby
s=[n=2];ARGV[0].to_i.times{n+=1until s.all?{|m|n%m>0};s<<p(n)}
7
Upvotes
r/codegolf • u/binarycat64 • Oct 16 '20
s=[n=2];ARGV[0].to_i.times{n+=1until s.all?{|m|n%m>0};s<<p(n)}
View all comments
Show parent comment
1
u/great_site_not Oct 17 '20
I got that from context--I figured it obviously wasn't a bit-shift operator like I'm most used to seeing, and C++'s stream insertion operator was the next thing i thought of, and arrays/lists/(whatever each scripting language likes to call its ordered collection of anys) are kinda similar to streams. Thanks for clarifying!
Yep yep. If a language lacks assignment expressions, I don't wanna golf in it!