-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Improve the generation performance of the result file and ad…
…ding some more information.
- Loading branch information
Showing
1 changed file
with
16 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
# Primes | ||
List of primes, for more ressources : [https://primes.utm.edu/](https://primes.utm.edu/) | ||
List of the first 50 millions primes, for more ressources : [https://primes.utm.edu/](https://primes.utm.edu/). | ||
|
||
Source: [https://primes.utm.edu/lists/small/millions/](https://primes.utm.edu/lists/small/millions/) | ||
|
||
# Shell | ||
# How to get the curated list ? | ||
|
||
These commands has been used on GNU/Linux (Ubuntu). | ||
``` Shell | ||
# Download the 50 archives. | ||
curl -OL https://www.utm.edu/~caldwell/primes/millions/primes[1-50].zip | ||
# Unzip | ||
find -maxdepth 1 -type f -name 'primes*.zip' -exec unzip {} \; | ||
for each in primes*.txt ; do awk 'NR>2 { for (i=1; i<=NF; i+=1) if ($i ~ /[0-9]+/ ) print($i) }' $each ; done | sort -h > primes.txt | ||
# Combine every text file in one file with one prime per line. | ||
for each in $(ls -1 primes*.txt| sort -t's' -n -k2) ; do awk 'NR>2 { for (i=1; i<=NF; i+=1) if ($i ~ /[0-9]+/ ) print($i) }' $each ; done > primes.txt | ||
# Check the result file | ||
sha256sum -c SHA256SUM.txt | ||
# Delete temporary files | ||
find -maxdepth 1 -type f \( -name 'primes*.zip' -or -name 'primes??.txt' -or -name 'primes?.txt' \) -delete | ||
``` | ||
|
||
# Use cases | ||
|
||
Solving some math problems from [https://projecteuler.net/](https://projecteuler.net/), has been easier with a precomputed list of primes. | ||
|