Skip to content

Commit

Permalink
[change] Improve the generation performance of the result file and ad…
Browse files Browse the repository at this point in the history
…ding some more information.
  • Loading branch information
SamCail committed Nov 15, 2022
1 parent 2fb225a commit 77f89fa
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions README.md
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.

0 comments on commit 77f89fa

Please sign in to comment.