Advertisement
CoineTre

JF-ExcBasic06. Strong Number

Jan 14th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String input = scanner.nextLine();
  7.         int sum = 0;
  8.         for (int i = 0; i < input.length() ; i++) {
  9.             int n = Integer.parseInt("" + input.charAt(i));
  10.             int factoSum = 1;
  11.             for (int j = n; j >= 1; j--) {
  12.                 factoSum *=j;
  13.             }
  14.             sum+= factoSum;
  15.         }
  16.         int number= Integer.parseInt(input);
  17.         if (sum == number){
  18.             System.out.println("yes");
  19.         }else{
  20.             System.out.println("no");
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement