We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 329e97c + c9751a9 commit 56115b5Copy full SHA for 56115b5
Prime_number
Prime_number.py
@@ -0,0 +1,18 @@
1
+import math
2
+while True:
3
+ try:
4
+ num = int(input("Enter a Number: "))
5
+ break
6
+ except ValueError:
7
+ print("Invalid Input")
8
+
9
+if num > 1:
10
+ for i in range(2,int(math.sqrt(num))): #Smallest Prime Factor of a Composite Number is less than or equal to Square Root of N
11
+ if (num % i) == 0:
12
+ print(num,"is NOT a Prime Number. It's indeed a COMPOSITE NUMBER")
13
14
+ else:
15
+ print(num,"is a PRIME NUMBER ")
16
17
+else:
18
+ print(num,"is NOT a Prime Number")
0 commit comments