From c27fa436b894a2cf9dfcd45e9df6c1eac156ff34 Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Wed, 27 May 2020 17:57:38 -0400 Subject: [PATCH] remove redundant file --- others/sieve_of_Eratosthenes.cpp | 60 -------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 others/sieve_of_Eratosthenes.cpp diff --git a/others/sieve_of_Eratosthenes.cpp b/others/sieve_of_Eratosthenes.cpp deleted file mode 100644 index e87ad4983..000000000 --- a/others/sieve_of_Eratosthenes.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Sieve of Eratosthenes is an algorithm to find the primes - * that is between 2 to N (as defined in main). - * - * Time Complexity : O(N) - * Space Complexity : O(N) - */ - -#include -using namespace std; - -#define MAX 10000000 - -int primes[MAX]; - -/* - * This is the function that finds the primes and eliminates - * the multiples. - */ -void sieve(int N) -{ - primes[0] = 1; - primes[1] = 1; - for (int i = 2; i <= N; i++) - { - if (primes[i] == 1) - continue; - for (int j = i + i; j <= N; j += i) - primes[j] = 1; - } -} - -/* - * This function prints out the primes to STDOUT - */ -void print(int N) -{ - for (int i = 0; i <= N; i++) - if (primes[i] == 0) - cout << i << ' '; - cout << '\n'; -} - -/* - * NOTE: This function is important for the - * initialization of the array. - */ -void init() -{ - for (int i = 0; i < MAX; i++) - primes[i] = 0; -} - -int main() -{ - int N = 100; - init(); - sieve(N); - print(N); -}