Advertisement
desito07

Perfect Number

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