HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>JS Perfect Number</h1> <script> var num = 496; var i = 1; var total = 0; for(i=1; i < num; i++) { if(num % i == 0) total += i; } if(total == num) document.write(num +" is a perfect number"); else document.write(num +" is not a perfect number"); </script> </body> </html>
OUTPUT
×

Save as Private