+ 1

How can I print prime numbers in python

Python

28th Oct 2019, 6:05 PM
Badmus Mubarak. O
Badmus Mubarak. O - avatar
3 Réponses
+ 3
The principle of calculating prime numbers is simple: a number is called prime,if it is only divisible by 1 or by itself. So if you want to check if a number n is prime, you have to divide this number by numbers in a range starting by 2 as lower bound ending with upper bound build by the value of n. therefore a modulo division is performed. if result of any division is 0, it is not a prime. This is simple but can be optimized specially when large numbers ha to be checked.
28th Oct 2019, 8:38 PM
Lothar
Lothar - avatar
+ 1
Atleast you should need to know when an integer is prime, and when not. To get more understanding about primes you can use pencil and paper, it is very good practice.
28th Oct 2019, 7:41 PM
Seb TheS
Seb TheS - avatar