Programming Examples

Java program to Input an integer and check whether it is a special number or not.


WAP to Input an integer and check whether it is a special number or not.

A special number is such a number whose sum of the factorials of each digit is the number itself. For example, 145 is a special number because 1! + 4! + 5! = 1 + 24 +120 = 145. Special numbers are also called factorion.

Solution

class SpecialNumber
{
	public static void main(String arr[])
	{
		int i,j,r,d;
		for(i=100;i<=999;i++)
		{
			r=0;
			for(j=i;j>0;j=j/10)
			{
				d=j%10;
				r=r*10+d;
			}
			if(r==i)
				System.out.println(i);
		}
	}
}
Output

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2024 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz