SHARE
TWEET

Perfect Number

a guest Oct 18th, 2019 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function perfectOrNot(number) {
  2.     let temp = 0;
  3.     for (let i = 1; i <= number / 2; i++) {
  4.         if (number % i === 0) {
  5.             temp += i;
  6.         }
  7.     }
  8.  
  9.     if (temp === number && temp !== 0) {
  10.         console.log("We have a perfect number!");
  11.     }
  12.     else {
  13.         console.log("It's not so perfect.");
  14.     }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top