Problem Statement:
The Sieve of Eratosthenes is a method for finding all primes up to (and possibly including) a given natural n
Explanation:
Suppose n = 100
Step 1: A/c to the algorithm we will mark all the numbers which are divisible by 2 and are greater than or equal to the square of it.
Step 2: Now move to next unmarked number 3 and mark all the numbers which are multiple of 3 and are greater than the square of it.
Now move to next unmarked number 5 and mark all the numbers which are multiple of 5 and are greater than the square of it.
Now move to next unmarked number 5 and mark all the numbers which are multiple of 5 and are greater than the square of it.
Code:
See you in the next article.
Until Then...
Byeeee
Subscribe by Email
Follow Updates Articles from This Blog via Email
No Comments