Guest User

Untitled

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