From 6ac91086cd8434a5bc6321bd0170bb935aaa9c3a Mon Sep 17 00:00:00 2001 From: neumannth67917 <neumannth67917@th-nuernberg.de> Date: Wed, 15 Jul 2020 13:33:45 +0200 Subject: [PATCH] Add explanation for sieve of eratosthenes --- .gitignore | 1 + Main.hs | 2 +- TheSieveOfEratosthenes.md | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 TheSieveOfEratosthenes.md diff --git a/.gitignore b/.gitignore index b09d2bf..154f851 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Own: *.exe +.idea # From https://raw.githubusercontent.com/github/gitignore/master/Haskell.gitignore dist diff --git a/Main.hs b/Main.hs index 7d4ab60..95af32f 100644 --- a/Main.hs +++ b/Main.hs @@ -1,3 +1,3 @@ import SieveOfEratosthenes -main = putStrLn (show (take 10 (primes) ) ) +main = putStrLn ("First 9 prime numbers: " ++ (show (take 9 (primes) ) ) ) diff --git a/TheSieveOfEratosthenes.md b/TheSieveOfEratosthenes.md new file mode 100644 index 0000000..803e8b1 --- /dev/null +++ b/TheSieveOfEratosthenes.md @@ -0,0 +1,18 @@ +# The Sieve of Eratosthenes + +1. Write down the successive "plurals": 2, 3, 4, ... +2. Repeat: + 1. Take the first number that is not circled or crossed out. + 2. Circle it. + 3. Cross out its proper multiples. +3. What is left (i.e. the circled numbers) are the successive prime numbers. + +**Example** + +``` + 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ... +(2) 3 x 5 x 7 x 9 xx 11 xx 13 xx 15 xx 17 xx 19 xx 21 xx 23 xx 25 ... +(2) (3) 5 7 x 11 13 xx 17 19 xx 23 25 ... +(2) (3) (5) 7 11 13 17 19 23 xx ... +... +``` -- GitLab