Advertisement
ThePeeters

IsPerfect

Feb 23rd, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import acm.program.ConsoleProgram;
  2.  
  3. /*
  4. * To change this license header, choose License Headers in Project Properties.
  5. * To change this template file, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8.  
  9. /**
  10. *
  11. * @author prb7
  12. */
  13. public class Problema1 extends ConsoleProgram{
  14. public void run(){
  15. }
  16. public boolean isPerfect(int n){
  17. int suma=1, n_aux=n/2;
  18. while(n_aux>1){
  19. if(n_aux>1){
  20. suma+=n_aux;
  21. }
  22. n_aux--;
  23. }
  24. return(n==suma);
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement