forked from tdamdouni/Pythonista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprime-number-finder.py
97 lines (89 loc) · 2.19 KB
/
prime-number-finder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# https://forum.omz-software.com/topic/3614/prime-number-finder/4
import time
print('Made by Yasas Kulatunga, Dhari Prashanth and Dhivy Prashanth')
print(' ')
number = int(input("Enter a Number: "))
print(' ')
time.sleep(0.5)
print('THINKING.')
time.sleep(0.5)
print('THINKING..')
time.sleep(0.5)
print('THINKING...')
time.sleep(0.5)
print(' ')
c = 0
while number:
for i in range(2,number):
if number % i == 0:
print(str(i),"times",str(number//i),"is",str(number))
time.sleep(0.3)
c = c + 1
if c == 0:
print(' ')
print(str(number),"has no factors apart from 1 and itself, therefore it is a prime number")
print(' ')
time.sleep(0.3)
else:
print(' ')
print(str(number),"is not a prime number, the number has factors more than 1 and the number itself.")
print(' ')
time.sleep(0.3)
number = int(input('Enter a number: '))
print(' ')
time.sleep(0.3)
c = 0
# --------------------
import time
print('Made by Yasas Kulatunga, Dhari Prashanth and Dhivy Prashanth')
print(' ')
number = int(input("Enter a Number: ").strip())
print(' ')
time.sleep(0.5)
print('THINKING.')
time.sleep(0.5)
print('THINKING..')
time.sleep(0.5)
print('THINKING...')
time.sleep(0.5)
print(' ')
while number:
for i in range(2, number):
if number % i == 0:
print('{} is not prime.'.format(number))
break
else:
print('{} is prime!'.format(number))
number = int(input("Enter a Number: ").strip())
# --------------------
import time
from math import sqrt
print('Made by Yasas Kulatunga, Dhari Prashanth and Dhivy Prashanth')
print(' ')
number = int(input("Enter a Number: ").strip())
maxfact = int(sqrt(number)-1)
print(' ')
time.sleep(0.5)
print('THINKING.')
time.sleep(0.5)
print('THINKING..')
time.sleep(0.5)
print('THINKING...')
time.sleep(0.5)
print(' ')
while number:
for i in range(2, maxfact):
if number % i == 0:
print('{} is not prime.'.format(number))
break
else:
print('{} is prime!'.format(number))
number = int(input("Enter a Number: ").strip())
maxfact = int(sqrt(number)-1)
# --------------------
maxfact = int(sqrt(number)-1) -> maxfact = int(sqrt(number))
# --------------------
for i in range(2, maxfact+1):
# --------------------
for i in [2]+list(range(3, maxfact+1,2)):
# --------------------