In this python program, we are given a number and we have to check whether the number is neon or not.

Neon Number is a number whose sum of digits of its square is equal to the original number.

Python Program for Neon Number

Steps to Check Neon Number in Python

  1. Take a number as input.
  2. Find Square of the number.
  3. Calculate the sum of digits of the square.
  4. If the square is equal to the number, then it is neon number, else not.

Neon Number in Python

num = int(input("Enter a number \n"))
sqr = num*num #square of num
sumOfDigit = 0

#calculating sum of digits of sqr
while sqr>0:
    sumOfDigit =sumOfDigit + sqr%10
    sqr = sqr//10

if (num == sumOfDigit):
    print("Neon Number \n")
    print("Not a Neon Number \n")

Language: Python 3


Neon Number in Python

That’s all we need to do, in order to check whether a number is neon or not in python 3. If you have any doubts then comment below.

This Post Has One Comment

Leave a Reply