Advertisement
Guest User

Untitled

a guest
May 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package BasicSyntaxEx1705;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Problem6StrongNum {
  6. public static void main(String[] args) {
  7. Scanner enter = new Scanner(System.in);
  8.  
  9. String num = enter.nextLine();
  10. int endInt = Integer.parseInt(num);
  11.  
  12. int factorialSum = 0;
  13. int lastNumToMultiply = 1;
  14.  
  15. for (int i = 0; i <= num.length() - 1; i++) {
  16. char currentNumChar = num.charAt(i);
  17. int currentNum = Character.getNumericValue(currentNumChar);
  18. for (int x = currentNum; x >= 1; x--) {
  19. lastNumToMultiply*=x;
  20. }
  21. factorialSum+=lastNumToMultiply;
  22. lastNumToMultiply = 1;
  23. }
  24.  
  25. if (endInt == factorialSum) {
  26. System.out.println("yes");
  27. } else {
  28. System.out.println("no");
  29. }
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement