forked from kaleemsiddiqu/edison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
math51-2.py
53 lines (44 loc) · 977 Bytes
/
math51-2.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
def even_odd_number(number,base):
even = []
while number >= base:
val = number % base
if val == 0:
even.append(number)
number -= 1
return even
def prime_number(number):
temp = 0
count = 2
val = number // 2
while count <= val:
temp = number % count
if temp == 0:
return 0
else:
count += 1
if temp != 0:
return number
def factors(number):
count = 1
sum = 0
factors = []
while count <= number:
temp = number % count
if temp == 0:
factors.append(count)
sum += count
count += 1
return factors, count
number = raw_input("Enter a number: ")
number = int(number)
print "Number of even numbers from 1 to %d is: " % number
for i in even_odd_number(number, 2):
print i
print "Number of odd numbers from 1 to %d is: " % number
for i in even_odd_number(number, 3):
print i
prime_result = prime_number(number)
if prime_result != 0
print "%d is a prime number" % number
else:
print "%d is not a prime number" % number