Compare commits

...

3 Commits

Author SHA1 Message Date
Shyamashrita Chatterjee
b75ead90ea
Merge d3fe84d023 into 2c67b48c21 2024-04-25 08:22:26 +08:00
Shyamashrita Chatterjee
d3fe84d023
Merge branch 'master' into hk 2020-10-06 18:29:13 +05:30
Shyamashrita
1718c91ed6 Armstrong Number added 2020-10-02 14:17:21 +05:30

View File

@ -0,0 +1,22 @@
// Check Armstrong Number of n Digits
let number = prompt("Enter a positive integer");
let numberOfDigits = number.length;
let sum = 0;
let temp = number;
while (temp > 0) {
let remainder = temp % 10;
sum += remainder ** numberOfDigits;
temp = parseInt(temp / 10);
if (sum == number) {
console.log(`${number} is an Armstrong number`);
}
else {
console.log(`${number} is not an Armstrong number.`);
}