-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18Eightteenth.py
More file actions
36 lines (32 loc) · 864 Bytes
/
Copy path18Eightteenth.py
File metadata and controls
36 lines (32 loc) · 864 Bytes
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
from Signature_folder.Signature import sign
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5)+1):
if n % i == 0:
return False
return True
def is_perfect(n):
if n < 2:
return False
return sum(i for i in range(1, n) if n % i == 0) == n
def is_armstrong(n):
digits = str(n)
power = len(digits)
return n == sum(int(d)**power for d in digits)
start = int(input("Enter start of range: "))
end = int(input("Enter end of range: "))
print("Prime numbers:")
for num in range(start, end+1):
if is_prime(num):
print(num, end=' ')
print("\nPerfect numbers:")
for num in range(start, end+1):
if is_perfect(num):
print(num, end=' ')
print("\nArmstrong numbers:")
for num in range(start, end+1):
if is_armstrong(num):
print(num, end=' ')
print()
sign()