Advertisement
jtentor

Evitar invocar a main recursivamente

Aug 24th, 2020
1,557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1.     public static void main(String[] args) {
  2.        
  3.         while (true) {
  4.             try {
  5.                 long n = Long.parseLong(scanner.next());
  6.                 System.out.println((sumDiv(n) - n) == n ? "Es número perfecto." : "No es número perfecto");
  7.                 break;
  8.             } catch (Exception e) {
  9.                 System.out.println("Se introdujo un número inválido, reintente.");
  10. //                main(args);
  11.             }
  12.            
  13.         }
  14.     }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement