Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (num) {
- let sumDivisors = 0;
- for (let i = 1; i <= num; i++) {
- if (num % i === 0) {
- sumDivisors += i;
- }
- if (sumDivisors >= num){
- console.log(sumDivisors === num ? "We have a perfect number!" : "It's not so perfect.");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement