Write a shell script to check whether a number is Armstrong number or not?
Answer Posted / kirtiranjan sahoo
read -p "Enter any number : " no
rev=0
temp=$no
while [ $no -ne 0 ]
do
dig=$(( $no%10 ))
rev=$(( $rev+$dig*$dig*$dig ))
no=$(( $no/10 ))
done
if [ $rev -eq $temp ]
then
echo "Armstrong"
else
echo "Not Armstrong"
fi
| Is This Answer Correct ? | 26 Yes | 23 No |
Post New Answer View All Answers
What is bash shell command?
How to get the first line from a file using just the terminal?
What does $0 mean in shell script?
shell script for reverse the string
Write a command sequence to find the count of each word?
What is an sh file?
What is the command to find out today's date?
Explain about login shell?
What does $$ mean in shell script?
How do I run a powershell script?
What is shell environment?
What is .sh file in mac?
What does echo $0 do?
What is the significance of $#?
What is basename in shell script?