---
# System prepended metadata

title: 13590 - smart little kai
tags: [I2P(I)Hu2022]

---

###### tags: `I2P(I)Hu2022`
# 13590 - smart little kai

> by schdoel

## Brief
Figure out if a number is a special number or not.
Special number is an armstrong number.
> An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits

## Solution

First, count the number of digits of each number ; *n*.
Then, power each digit to *n*, and sum it all together.
**Do not use pow from math.h, because pow will return double. There may be floating point errors when used directly in this way. You can use for loop instead to calculate the powers. ^^**


## Reference Code
```cpp=
#include <stdio.h>

int main() {
  int num;
  while (scanf("%d", &num)!=EOF) {
    int check, r, result = 0, n = 0;
    check = num;
    while (check != 0) {
      check /= 10;
      ++n;
    }
    check = num;
    while (check != 0) {
      r = check % 10;
      int temp = r;
      for(int i=1; i<n; i++) temp *= r;
      result += temp;
      check /= 10;
    }
    if (result == num) printf("Yes it is.\n");
    else printf("No it is not.\n");
  }
  return 0;
}
```