From 16be0f2763d38135c77dc044aa69173e9b3c894a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=BBarnecki?= Date: Mon, 19 Aug 2024 06:32:25 +0200 Subject: [PATCH] Sieve of Eratosthenes algorithm (#159) Co-authored-by: Michal Zarnecki --- DIRECTORY.md | 2 ++ Maths/EratosthenesSieve.php | 30 +++++++++++++++++++++++++++ tests/Maths/EratosthenesSieveTest.php | 16 ++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 Maths/EratosthenesSieve.php create mode 100644 tests/Maths/EratosthenesSieveTest.php diff --git a/DIRECTORY.md b/DIRECTORY.md index 784ee99f..95a62b4c 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -57,6 +57,7 @@ * [Problem7](./Maths/ProjectEuler/Problem7.php) * [Problem8](./Maths/ProjectEuler/Problem8.php) * [Problem9](./Maths/ProjectEuler/Problem9.php) + * [Eratosthenessieve](./Maths/EratosthenesSieve.php) ## Searches * [Binarysearch](./Searches/BinarySearch.php) @@ -119,6 +120,7 @@ * Maths * [Mathstest](./tests/Maths/MathsTest.php) * [Projecteulertest](./tests/Maths/ProjectEulerTest.php) + * [Eratosthenessievetest](./tests/Maths/EratosthenesSieveTest.php) * Searches * [Searchestest](./tests/Searches/SearchesTest.php) * Sorting diff --git a/Maths/EratosthenesSieve.php b/Maths/EratosthenesSieve.php new file mode 100644 index 00000000..d0380d09 --- /dev/null +++ b/Maths/EratosthenesSieve.php @@ -0,0 +1,30 @@ +assertEquals($result, [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]); + } +}