Strong Number

Strong number is a number whose sum of all digits’ factorial is equal to the number ‘n’. Factorial implies when we find the product of all the numbers below that number including that number and is denoted by ! (Exclamation sign), For example: 4! = 4x3x2x1 = 24.

Program:-

package payilagam.institution;

public class Strong {

	public static void main(String[] args) 
	{
		int num= 145;
		int rem;
		int i =1;
		int fact = 1;
		int total=0;
		while(num>0)
		{
			 rem = num%10;
			
			 while(i<=rem) 
			 {
				 fact=fact*i;
				i++;
			 }
			 total=total+fact;
			 num=num/10;
			 i=1;
			 fact=1;
			 }
		
		System.out.println(total);
			
			 }
	}

	
	


Output Screenshot:-

Leave a Reply

Create your own website, free on WordPress.com.Create your own website.
Start free