Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int factorial = 1;
- String input = scanner.nextLine();
- int number = 1;
- int endSum = 0;
- int inputInt = Integer.valueOf(input);
- String result = null;
- for (int p = 0; p < input.length();p++) {
- number = Character.getNumericValue(input.charAt(p));
- for (int i = 1; i <= number; i++) {
- factorial=factorial* i;
- } // calculate a singular digit factorial
- endSum+=factorial;
- factorial = 1; // reset single digit factorial calculcation for next digit
- }
- if (endSum == inputInt) {
- result = "yes";
- } else {
- result = "no";
- }
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement