Armstrong number in shell script
Armstrong number is a integer number which is equal to the sum of cube of each digit of its number. For example 153 is a armstrong number because 153 is equal to 13+53+33
Armstrong number in shell script can be found by adding the the cube of each digit of the number
Given a number n by the user determine whether the given number is Armstrong number or not by calculating sum of cube of each digit of its number.
![](https://linuxteach.wordpress.com/wp-content/uploads/2022/11/flat-black-friday-2022-1.png?w=1024)
this program will check whether the number is armstrong or not using while and if else.if number is armstrong then it will display number is armstrong otherwise it will display number is not armstrong.
echo -n “Enter the number: “
read Number
Length=${#Number}
Sum=0
OldNumber=$Number
while [ $Number -ne 0 ]
do
Rem=$((Number%10))
Number=$((Number/10))
Power=$(echo “$Rem ^ $Length” | bc )
Sum=$((Sum+$Power))
done
if
[ $Sum -eq $OldNumber ]
then
echo “$OldNumber is an Armstrong number”
else
echo “$OldNumber is not an Armstrong number”
fi