-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharmstrong.html
More file actions
37 lines (31 loc) · 909 Bytes
/
armstrong.html
File metadata and controls
37 lines (31 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=\, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
Enter any Number: <input id="no_input">
<button onclick="armstr()">Check</button></br></br>
<script>
function armstr() {
var arm = 0, a, b, c, d, num;
num = Number(document.getElementById("no_input").value);
temp = num;
while (temp > 0) {
a = temp % 10;
temp = parseInt(temp / 10); // convert float into Integer
arm = arm + a * a * a;
}
if (arm == num) {
alert("Armstrong number");
}
else {
alert("Not Armstrong number");
}
}
</script>
</body>
</html>