diff --git a/algorithms/Python/README.md b/algorithms/Python/README.md index b2be029d..7cfd6fa9 100644 --- a/algorithms/Python/README.md +++ b/algorithms/Python/README.md @@ -83,3 +83,7 @@ ## Queues - [First in First out Queue](queues/fifo-queue.py) + + +##Number Theory +- [Prime Number Checker][number_theory/prime_number.py] \ No newline at end of file diff --git a/algorithms/Python/number_theory/prime_number.py b/algorithms/Python/number_theory/prime_number.py new file mode 100644 index 00000000..54190ab1 --- /dev/null +++ b/algorithms/Python/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") \ No newline at end of file