forked from HarshCasper/NeoAlgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Neon_number.py
48 lines (40 loc) · 965 Bytes
/
Neon_number.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
"""
Python program to check if the number is Neon number or not.
We can Say that the number is Neon number if its sum of digits
of square is equal to the number.
"""
def Neon_number(number) :
# Calculating the square of the number
square_number = pow(number,2)
# Calculating the sum of digits of the square of the number
sum_of_digits = 0
while square_number != 0 :
digit = square_number % 10
sum_of_digits += digit
square_number = square_number // 10
if sum_of_digits == number :
print(number,"is a Neon number")
else :
print(number,"is not a Neon number")
number = int(input("Enter a number:"))
Neon_number(number)
"""
Sample of input/output:
Example 1:
Input:
Enter a Number: 9
Output:
9 is a Neon number
Example 2:
Input:
Enter Number: 5
Output:
5 is not a Neon number
Example 3:
Input:
Enter a Number: 0
Output:
0 is a Neon number
Space Complexity O(1)
Time Complexity O(log(n))
"""