#include <stdio.h>
#include <math.h>
int main() {
int num=153, originalNum, remainder, result = 0, n = 0;
originalNum = num;
// Calculate the number of digits in the number
while (originalNum != 0) {
originalNum /= 10;
n++;
}
// originalNum = num;
// Calculate the sum of the digits raised to the power of n
while (originalNum != 0) {
remainder = originalNum % 10;
result
+= pow(remainder
, n
); originalNum /= 10;
}
// Check if the result equals the original number
if (result == num) {
printf("%d is an Armstrong number.\n", num
); } else {
printf("%d is not an Armstrong number.\n", num
); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBudW09MTUzLCBvcmlnaW5hbE51bSwgcmVtYWluZGVyLCByZXN1bHQgPSAwLCBuID0gMDsKCiAgICBvcmlnaW5hbE51bSA9IG51bTsKCiAgICAvLyBDYWxjdWxhdGUgdGhlIG51bWJlciBvZiBkaWdpdHMgaW4gdGhlIG51bWJlcgogICAgd2hpbGUgKG9yaWdpbmFsTnVtICE9IDApIHsKICAgICAgICBvcmlnaW5hbE51bSAvPSAxMDsKICAgICAgICBuKys7CiAgICB9CgogICAgLy8gb3JpZ2luYWxOdW0gPSBudW07CgogICAgLy8gQ2FsY3VsYXRlIHRoZSBzdW0gb2YgdGhlIGRpZ2l0cyByYWlzZWQgdG8gdGhlIHBvd2VyIG9mIG4KICAgIHdoaWxlIChvcmlnaW5hbE51bSAhPSAwKSB7CiAgICAgICAgcmVtYWluZGVyID0gb3JpZ2luYWxOdW0gJSAxMDsKICAgICAgICByZXN1bHQgKz0gcG93KHJlbWFpbmRlciwgbik7CiAgICAgICAgb3JpZ2luYWxOdW0gLz0gMTA7CiAgICB9CgogICAgLy8gQ2hlY2sgaWYgdGhlIHJlc3VsdCBlcXVhbHMgdGhlIG9yaWdpbmFsIG51bWJlcgogICAgaWYgKHJlc3VsdCA9PSBudW0pIHsKICAgICAgICBwcmludGYoIiVkIGlzIGFuIEFybXN0cm9uZyBudW1iZXIuXG4iLCBudW0pOwogICAgfSBlbHNlIHsKICAgICAgICBwcmludGYoIiVkIGlzIG5vdCBhbiBBcm1zdHJvbmcgbnVtYmVyLlxuIiwgbnVtKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=