From 95eb6fc19ea65dd1c2fab3b65053fce8e6a7a3ab Mon Sep 17 00:00:00 2001 From: Aarushi gupta <115031972+aaruhsigupta@users.noreply.github.com> Date: Fri, 6 Oct 2023 23:46:05 +0530 Subject: [PATCH] Create Sieve of Eratosthenes This is DSA C++ language code for Sieve of Erastosthenes --- Sieve of Eratosthenes | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Sieve of Eratosthenes diff --git a/Sieve of Eratosthenes b/Sieve of Eratosthenes new file mode 100644 index 0000000..a2ead8d --- /dev/null +++ b/Sieve of Eratosthenes @@ -0,0 +1,33 @@ +//Sieve of Eratosthenes +void primeSieve(int n) +{ + int prime[100]={0}; + for(int i =2; i<=n; i++) + { + if(prime[i]==0) + { + for(int j = i*i; j<=n; j+=i) + { + prime[j]=1; + } + } + } + for(int i =2; i<=n; i++) + { + if(prime[i]==0) + { + cout<>n; + primeSieve(n); + + + return 0; +}