programming-examples/js/Conditional/Write a JavaScript program to find the armstrong numbers of 3 digits..js
2019-11-15 12:59:38 +01:00

19 lines
487 B
JavaScript

function three_digit_armstrong_number()
{
for (var i = 1; i < 10; ++i)
{
for (var j = 0; j < 10; ++j)
{
for (var k = 0; k < 10; ++k)
{
var pow = (Math.pow(i,3) + Math.pow(j,3) + Math.pow(k,3));
var plus = (i * 100 + j * 10 + k);
if (pow == plus)
{
console.log(pow);
}
}
}
}
}
three_digit_armstrong_number();