Advertisement
divanov94

Untitled

Jun 12th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function perfect(num){
  2.     let divisors=0;
  3.     for(let i=num-1;i>0;i--){
  4.         if(num%i==0){
  5.             divisors+=i;
  6.         }        
  7.     }
  8.     if(divisors==num){
  9.         console.log("We have a perfect number!");
  10.        
  11.     }else {
  12.         console.log("It's not so perfect.")
  13.     }
  14.    
  15.    
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement