# 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

``````import java.util.Scanner;

public class ArmstrongNumber {
private static boolean 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;
}
}

public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int number;

System.out.print("Enter a number to check for armstrong:  ");

if (checkArmstrong(number)) {
System.out.print(number + " is an armstrong number");
} else {
System.out.print(number + " is not an armstrong number");
}

}
}``````
##### Output
``````Enter a number to check if armstrong number:  8208
8208 is an armstrong number``````

## Armstrong Number Series

``````import java.util.Scanner;

public class ArmstrongNumberSeries {
private static boolean 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;
}
}

public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int max;

System.out.print("Enter the upper bound to find armstrong numbers:  ");
``````Enter the upper bound to find armstrong numbers:  1000