
To display Armstrong numbers from 1 to 100, firstly use a while loop.
Example
while (val <= 1000) {
}Now inside the while loop, set conditions for first, second and third digit.
Example
d1 = val - ((val / 10) * 10); d2 = (val / 10) - ((val / 100) * 10); d3 = (val / 100) - ((val / 1000) * 10);
Since, Armstrong number checks for the cube of all the digits.
Example
res = (d1 * d1 * d1) + (d2 * d2 * d2) + (d3 * d3 * d3);
if (res == val) {
Console.WriteLine(temp);
}如果一个数字的每个位数的立方和等于该数字本身,则该数字是一个阿姆斯特朗数,例如,153。











