by Dinesh Thakur

If sum of factorial of each digit of the number is same as the actual number then that number is called as strong number.

Algorithm for Strong Number:

 

Here the method has one formal argument b and it returns an integer value to its caller.

step 1: Set fact= 1

step 2: Read b

step 3: Set c=b

step 4: Repeat through step-6 until (c > 0)

step 5: fact=fact*c

step 6: c=c-1

step 7: return fact

step 8: Exit

 

Here is the Java Example for Strong Number:

import java.util.Scanner;

public class StrongNumber
{
               public static void main(String args[])
              {
                 StrongNumber ss=new StrongNumber();
                 int a,b,r,s=0;
                 Scanner sl=new Scanner(System.in);
                 System.out.println("Enter A Number");
                 b=sl. nextInt() ;
                 a=b;
                 while(b>0)
                       {
                           r=b%10;
                           s=s+ss.fact(r);
                           b=b/10;
                       }
                  if(a==s)
                     System.out.println(a+" is a strong number");
                  else
                     System.out.println(a+" is not a strong number");
                }
                       int fact(int i)
                             {
                                 int f,j;
                                 f=1;
                                for(j=i ;j>0;j--)
                                     f=f*j;
                                     return f;
                              }
}

Strong Number Program in Java Example