Added Prime Number checker alorithm
parent
6f19b452ea
commit
da4a105bb7
|
@ -83,3 +83,7 @@
|
||||||
|
|
||||||
## Queues
|
## Queues
|
||||||
- [First in First out Queue](queues/fifo-queue.py)
|
- [First in First out Queue](queues/fifo-queue.py)
|
||||||
|
|
||||||
|
|
||||||
|
##Number Theory
|
||||||
|
- [Prime Number Checker][number_theory/prime_number.py]
|
|
@ -0,0 +1,16 @@
|
||||||
|
#TO CHECK WHETHER A NUMBER IS PRIME OR NOT
|
||||||
|
|
||||||
|
|
||||||
|
N = int(input())
|
||||||
|
|
||||||
|
PRIME = True
|
||||||
|
|
||||||
|
for i in range(2, int(N**0.5+1)):
|
||||||
|
if N%i==0:
|
||||||
|
PRIME = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if PRIME:
|
||||||
|
print(f"{N} is prime")
|
||||||
|
else:
|
||||||
|
print(f"{N} is not prime")
|
Loading…
Reference in New Issue