stoyanoff

StrongNumber_06

Sep 20th, 2020
786
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package bg.softuni.fundamentals.EXERCISE;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class StrongNumber_06 {
  6.     public static void main(String[] args) {
  7.         Scanner myScanner = new Scanner(System.in);
  8.  
  9.         String number = myScanner.nextLine();
  10.  
  11.         int sumFac = 0;
  12.  
  13.         for (int i = 0; i < number.length(); i++) {
  14.             int j = Integer.parseInt(String.valueOf(number.charAt(i)));
  15.             int fact = 1;
  16.             for (int k = 1; k <= j; k++) {
  17.                 fact = fact * k;
  18.             }
  19.             sumFac += fact;
  20.  
  21.         }
  22.         if (sumFac == Integer.parseInt(number)) {
  23.             System.out.println("yes");
  24.         } else {
  25.             System.out.println("no");
  26.         }
  27.  
  28.     }
  29. }
  30.  
RAW Paste Data