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 c in shell script?
What is eval in shell script?
Is shell scripting easy to learn?
What are the two files of crontab command?
What does $0 mean in shell script?
I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?
When should shell programming/scripting not be used?
What is awk in shell script?
What are the types of script?
How will you connect to a database server from linux?
What is bash shell command?
what is info area how many types?
What lives in a shell?
What is echo in shell?
How can we find the process name from its process id?