0

How to print a prime number pattern in Python

2 3 5 7 11 13 17 19 23 29

11th Jun 2022, 5:54 AM
Harsh Porwal HP
2 Respostas
+ 3
thetechguy, you are not giving an accurate description of the Sieve of Eratosthenes. For a true description see this: https://www.sololearn.com/learn/969/?ref=app
11th Jun 2022, 8:20 AM
Brian
Brian - avatar
+ 1
To do this you can use the Sieve of Eratosthenes. Basically, you can check if a number is prime by checking its divisibility with all the primes less than that number. Example: 79 Divisble by 2? No Divisble by 3? No ... Divisible by 73? No Therefore 79 is prime. For how to code it, you could either use recursive functions or nested for and if statements.
11th Jun 2022, 7:11 AM
thetechguy
thetechguy - avatar