Why is it that when I choose the range from 1 to 27, the computer sees the perfect number 6, and if it is from 1 to 30, | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Why is it that when I choose the range from 1 to 27, the computer sees the perfect number 6, and if it is from 1 to 30,

function perfect(min, max) { let n = 0; for (let i = 1; i < min; i++) { if (min % i == 0) { n += i; } } if (n == min) { console.log (`Your ${min} is perfect`); } else if (min != max){ min++; perfect(min, max); } } perfect(min = +prompt('Enter the minimum number of your range'), max = +prompt('Enter the maximum number of your range'))

26th Apr 2021, 10:06 AM
Тимур Завьялов
Тимур Завьялов - avatar
1 ответ
0
it does not see the perfect number 28, and also with the perfect number 498
26th Apr 2021, 10:07 AM
Тимур Завьялов
Тимур Завьялов - avatar