Timeline for List of primes under a million
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 29, 2015 at 17:47 | history | edited | saeedn | CC BY-SA 3.0 |
taking out 4 chars on shorter solution
|
Jul 17, 2014 at 19:06 | history | edited | user16402 | CC BY-SA 3.0 |
deleted 6 characters in body
|
May 13, 2014 at 16:32 | comment | added | user16402 |
@technosaurus seq and factor are in coreutils , so it's legitimate. sed is also pretty ubiquitous. coreutils can be treated like a built-in. Bash without coreutils is like C++ without the STL.
|
|
May 13, 2014 at 16:28 | comment | added | technosaurus |
seq, factor and sed are external programs, this may as well be c p where c is a symlink to cat and p is a text file with primes up to a million... can you do it with shell builtins?
|
|
Apr 2, 2014 at 23:23 | comment | added | Dennis |
seq 1e6|factor|awk '$0=$2*!$3' is a bit shorter.
|
|
Jun 11, 2012 at 12:23 | comment | added | saeedn | Yes, that awk script is about 25% faster :) | |
Jun 11, 2012 at 9:03 | comment | added | manatwork |
awk is faster and shorter in filtering this: seq 2 1000000|factor|awk '!$3&&$0=$2' – 37 characters. Or if you filter out the 1 case with awk , but the code's length is the same: seq 1000000|factor|awk 'NF==2&&$0=$2' .
|
|
May 26, 2012 at 9:53 | history | edited | saeedn | CC BY-SA 3.0 |
improved code 2
|
May 26, 2012 at 9:50 | comment | added | saeedn | I was applying this improvement before I saw your comment ;) | |
May 26, 2012 at 9:16 | comment | added | Delan Azabani |
This can also further be improved to: seq 2 1000000|factor|sed 's/[0-9]*: //g;/ /d'
|
|
May 26, 2012 at 9:15 | comment | added | saeedn | yes you're right. I wrote my sed command clean, not golfed :P | |
May 26, 2012 at 9:13 | comment | added | Delan Azabani |
This can be improved to: seq 2 1000000|factor|sed 's/[0-9]*: //g;/^.* .*$/ d'
|
|
May 26, 2012 at 9:07 | history | answered | saeedn | CC BY-SA 3.0 |