Timeline for List of first n prime numbers most efficiently and in shortest code
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 21, 2018 at 2:45 | review | Suggested edits | |||
Feb 21, 2018 at 4:26 | |||||
Feb 21, 2018 at 2:40 | comment | added | Richie |
Well changing it to (2..(1.0/0)).lazy.select{|i|!(2...i).any?{|j|i%j<1}}.first(n) will result in 61 chars.
|
|
Sep 2, 2015 at 5:55 | comment | added | Qqwy |
Or even: (This makes the solution less efficient, but it does not change the upper O(n²) bound) (2..(1.0/0)).lazy.select{|i|(2..i).one?{|j|i%j<1}}.take(n).to_a . This shaves off two more characters.
|
|
Sep 2, 2015 at 5:50 | comment | added | Qqwy |
You can shave one char off by changing it to (2..(1.0/0)).lazy.select{|i|!(2...i).any?{|j|i%j<1}}.take(n).to_a
|
|
S Feb 4, 2014 at 14:37 | review | Late answers | |||
Feb 4, 2014 at 16:41 | |||||
S Feb 4, 2014 at 14:37 | review | First posts | |||
Feb 4, 2014 at 16:22 | |||||
Feb 4, 2014 at 14:20 | history | answered | Uri Agassi | CC BY-SA 3.0 |