Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Problem6 {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. String input = scanner.nextLine(); // 145
  9. char sum = 1;
  10. char totalSum = 0;
  11.  
  12. for (int i = input.length()-1 ; i >=0 ; i--){ // 5
  13. int num = Integer.parseInt("" + input.charAt(i));
  14. if (num == 0 ){
  15. sum += 0;
  16. }else {
  17. while (num>=1){
  18. sum *= num;
  19. num--;
  20. }
  21. }
  22. totalSum +=sum;
  23. }
  24. int nummm = Integer.parseInt(input);
  25.  
  26. if (totalSum==nummm){
  27. System.out.println("yes");
  28. }else{
  29. System.out.println("no");
  30. }
  31.  
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement