[PYTHON] Discrimination of prime numbers

Recently I'm studying python. Leave a note.

Discrimination of prime numbers

>>> 
2  is a prime number
3  is a prime number
5  is a prime number
7  is a prime number
11  is a prime number
13  is a prime number
17  is a prime number
19  is a prime number
23  is a prime number
29  is a prime number
31  is a prime number
37  is a prime number
41  is a prime number
43  is a prime number
47  is a prime number
53  is a prime number
59  is a prime number
61  is a prime number
67  is a prime number
71  is a prime number
73  is a prime number
79  is a prime number
83  is a prime number
89  is a prime number
97  is a prime number

code

Prime number.py


import math
n = 100 
for num in range(2,n):
    for i in range(2, math.floor(num**0.5)):
        if num % i == 0:
            break
    else:
        print(num, " is a prime number")

Recommended Posts

Discrimination of prime numbers
Project Euler 10 "Sum of Prime Numbers"
Prime numbers and divisors
Project Euler # 10 "sum of prime numbers" in Python
Recursively find prime numbers
Prime numbers in Python
This year's prime numbers
Discrimination of mahjong waiting form
Determine prime numbers with python
I tried to create a list of prime numbers with python
It's a prime number ... Counting prime numbers ...
Law of large numbers in python
[Python] nCr mod Compute prime numbers
Aggregation and visualization of accumulated numbers
Check the number of prime numbers less than or equal to n
Algorithm learned with Python 4th: Prime numbers
String conversion of a list containing numbers
I searched for prime numbers in python
Solve with Ruby and Python AtCoder ABC084 D Cumulative sum of prime numbers