Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
881 B
2
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h3> ENTER THE NO </h3>
    <input type="text" id="number"/>
    <button onclick="checkNumber()">SUBMIT</button>
    <script>
        function checkNumber() {
            var no = parseInt(document.getElementById("number").value);
            var sum = 0;
            for (var i = 1; i < no; i++) {
                if (no % i == 0) {
                    sum += i;
                }
            }
            if (sum == no) {
                alert("Perfect number");
            } else if (sum > no) {
                alert("Abundant number");
            } else {
                alert("Deficient number");
            }
        }
    </script>
</body>
</html>
Leave a Comment