chore(Java): add sieve of eratosthenes (#1117)

pull/1118/head
mihirsuman0131@gmail.com 2022-12-24 15:13:32 +05:30
parent 3e80843311
commit 2a6e20691b
1 changed files with 1 additions and 1 deletions

View File

@ -8,7 +8,7 @@
2. Start with a smallest prime number, ie p = 2p=2. 2. Start with a smallest prime number, ie p = 2p=2.
3. Mark all the multiples of pp which are less than nn as composite. To do this, mark the value of the numbers (multiples of pp) in the generated list as 0. Do not mark pp itself as composite. 3. Mark all the multiples of pp which are less than nn as composite. To do this, mark the value of the numbers (multiples of pp) in the generated list as 0. Do not mark pp itself as composite.
4. Assign the value of p to the next prime. The next prime is the next non-zero number in the list which is greater than p. 4. Assign the value of p to the next prime. The next prime is the next non-zero number in the list which is greater than p.
5. Repeat the process until p is less than or equal to square root of n p\le \sqrt { n }p n 5. Repeat the process until p is less than or equal to square root of n.
*/ */