forked from souravjain540/Basic-Python-Programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharmstrong.py
More file actions
Latest commit
36 lines (25 loc) · 578 Bytes
/
Copy patharmstrong.py
File metadata and controls
36 lines (25 loc) · 578 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
defpower(x, y):
ify==0:
return1
ify%2==0:
returnpower(x, y//2) *power(x, y//2)
returnx*power(x, y//2) *power(x, y//2)
deforder(x):
n=0
while (x!=0):
n=n+1
x=x//10
returnn
defisArmstrong(x):
n=order(x)
temp=x
sum1=0
while (temp!=0):
r=temp%10
sum1=sum1+power(r, n)
temp=temp//10
return (sum1==x)
x=153
print(isArmstrong(x))
x=1253
print(isArmstrong(x))