Neon number:- A neon number is a number where the sum of digits of square of the number is equal to the number. For example number is 9 so 9=>9*9=>81=>8+1=9 which is equal to 9 so 9 is neon number, suppose number is 5 so 5=>5*5=>25=>2+5=>7 which is not equal to 5 to 5 is not neon number.
Algorithm:-
(1)start
(2)Take a number from user
(3)store the number in temporary variable
(4)find square of number and store in variable n
(5)find the sum of digits of number n and store value in sum variable
(6)compare temporary variable value to sum variable if equals print number is
Neon number else print number is not neon number
(7)stop
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestApplicationOnly
{
class Program
{
static void Main(string[] args)
{
int num, rem, sum = 0, temp;
Console.WriteLine("Enter the number :");
num = Convert.ToInt32(Console.ReadLine());
temp = num;
int n = num * num;
while (n != 0)
{
rem = n % 10;
sum = sum + rem;
n = n / 10;
}
if (temp == sum)
{
Console.WriteLine("Number is neon number");
}
else
{
Console.WriteLine("Number is not neon number");
}
Console.ReadKey();
}
}
}
//output:
//Enter the number :
//9
//Number is neon number
//Enter the number :
//15
//Number is not neon number
0 टिप्पणियाँ