Skip to content

Commit bca3497

Browse files
committed
prime nbr check
checks if a nbr is prime or not
1 parent 74cd41c commit bca3497

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Scripts/prime_numbers.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'''
2+
Created on Oct 15, 2019
3+
4+
@author: Big
5+
'''
6+
n=int(input("write a number >0:"))
7+
ok=1
8+
if(n==0 or n==1):
9+
ok=0
10+
else:
11+
if(n%2==0):
12+
if(n!=2):
13+
ok=0
14+
else:
15+
d=2
16+
while(d<=n//2):
17+
if(n%d==0):
18+
ok=0
19+
break
20+
if(d==2):
21+
d=3
22+
else:
23+
d+=2
24+
if(ok==1):
25+
print("prime")
26+
else:
27+
print("!prime")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy