# Armstrong number

An Armstrong number (also called a plus perfect number or narcissistic number) is a number equal to the sum of the nth power of the digits, where n is the quantity of digits in the number.

## Check Armstrong Number

``````#include &lt;iostream&gt;
using namespace std;

bool checkArmstrong(int number) {
int temp, remainder, i, counter = 0, result = 0, power;
temp = number;

while (temp != 0) {
temp /= 10;
counter++;
}
temp = number;

while (temp != 0) {
remainder = temp % 10;

power = 1;
i = counter;
while (i != 0) {
power *= remainder;
i--;
}

result += power;
temp /= 10;
}

if (number == result) {
return true;
} else {
return false;
}
}

int main() {
int number;

cout << "Enter a number to check for armstrong:  ";
cin >> number;

if (checkArmstrong(number)) {
cout << number << " is an armstrong number";
} else {
cout << number << " is not an armstrong number";
}

return 0;
}``````
##### Output
``````Enter a number to check for armstrong:  371
371 is an armstrong number``````

## Armstrong Number Series

``````#include &lt;iostream&gt;
using namespace std;

bool checkArmstrong(int number) {
int temp, remainder, i, counter = 0, result = 0, power;
temp = number;

while (temp != 0) {
temp /= 10;
counter++;
}
temp = number;

while (temp != 0) {
remainder = temp % 10;

power = 1;
i = counter;
while (i != 0) {
power *= remainder;
i--;
}

result += power;
temp /= 10;
}

if (number == result) {
return true;
} else {
return false;
}
}

int main() {
int max;

cout << "Enter the upper bound to find armstrong numbers: ";
cin >> max;

cout << "Armstrong Number Series:";
for (int i = 1; i <= max; i++) {
if (checkArmstrong(i)) {
cout << i << " ";
}
}

return 0;
}``````
##### Output
``````Enter the upper bound to find armstrong numbers: 1000
Armstrong Number Series:1 2 3 4 5 6 7 8 9 153 370 371 407``````