Strong Number in Java

Table of Contents

Strong Number in Java

What is a Strong Number?

A Strong number is a number whose sum of all digits factorial is equal to the number. For instance,145 is a Strong Number as 1! + 4! + 5! is equal to 145 only.

Compile and Run the following code with Command-Prompt Or download Notepad++

For Compilation javac

For Execution java Sample

import java.util.Scanner;
class Sample
  public static void main(String args[])
    int n,i,p,r,sum = 0,num;
    Scanner sc = new Scanner(;
    System.out.println("Enter the number of your choice: ");
    n = sc.nextInt();
    num = n;
    while(num ! =0)
      i = 1;
      p = 1;
      r = num % 10;
        p = p*i;
    if(sum == num)
      System.out.println("This is a Strong Number");
      System.out.println("This is not a Strong Number");
Previous Armstrong Number in Java
Next Neon Number in Java

Leave a Reply