SHARE
TWEET

Perfect Number

Lulunga Jun 20th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(num){
  2.   let sumfDivisors = 0;
  3.   for (let i = 1; i < num; i++) {
  4.       if (num%i===0) {
  5.         sumfDivisors+=i;
  6.       }
  7.   }
  8.   if (num===sumfDivisors) {
  9.       console.log(`We have a perfect number!`);
  10.   } else {
  11.       console.log(`It's not so perfect.`);
  12.   }
  13. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top