function armstrong(n) {
let reminder = 0, sum = 0;
const total_digits = n.toString().length;
while (n > 0) {
reminder = n % 10;
sum += Math.pow(reminder, total_digits);
n = Math.floor(n / 10);
}
return sum;
}
let n = 153; // 1*1*1 + 5*5*5 + 3*3*3 = 153
if (n == armstrong(n))
console.log("Armstrong number");
else
console.log("Not armstrong number");
n = 9474; // 9*9*9*9 + 4*4*4*4 + 7*7*7*7 + 4*4*4*4 = 9474
if (n == armstrong(n))
console.log("Armstrong number");
else
console.log("Not armstrong number");
/*
run:
Armstrong number
Armstrong number
*/