-
Notifications
You must be signed in to change notification settings - Fork 263
/
Number
75 lines (28 loc) · 978 Bytes
/
Number
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
def power_1(A, B):
if B == 0:
return 1
if B % 2 == 0:
return power_1(A, B // 2) * power(A, B // 2)
return A * power(A, B // 2) * power(A, B // 2)
# Function for calculating "order of the number"
def order_1(A):
# Variable for storing the number
N = 0
while (A != 0):
N = N + 1
A = A // 10
return N
# Function for checking if the given number is Armstrong number or not
def is_Armstrong(A):
N = order_1(A)
temp_1 = A
sum_1 = 0
while (temp_1 != 0):
R_1 = temp_1 % 10
sum_1 = sum_1 + power_1(R_1, N)
temp_1 = temp_1 // 10
# If the above condition is satisfied, it will return the result
return (sum_1 == A)
# Driver code
A = int(input("Please enter the number to be checked: "))
print(is_Armstrong(A))