Neon number is number,in which sum of digits of square of number, is same as number itself
For example 9 is neon number
- square of 9 is 81.
- Sum of digits of square i.e. 81 is 9.
- Sum of digits (9) and number(9) is matching.
neon.py
iSquare=0
iDigit=0
iSum=0
//Input number and convert to numeric form
iNumber=int(input(“Please enter a number: “))
//Square the input number
iSquare=iNumber**2
//Calculate sum of digits of square
while iSquare>0:
iDigit=iSquare%10
iSum=iSum+iDigit
iSquare=iSquare//10
//Compare sum of digits and input number
if iSum==iNumber:
print(iNumber,” is neon number”)
else:
print(iNumber,” is not neon number”)
Output
You must be logged in to post a comment.