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


Please Help Members By Posting Answers For Below Questions

How do I run a script on mac?

568


How does ls command work?

583


What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?

559


What will happen to my current process when I execute a command using exec?

536


Why do we use shell scripting?

547






What is a file basename?

592


How to print pid of the current shell?

602


What is bash shell command?

557


What is the use of .sh file?

598


What is c in shell script?

633


How to get script name inside a script?

546


What is a batch file used for?

558


Set up a Sev 2 alert when the Primary WA service fails. A windows batch script needs to be created that will monitor the WA service on the Primary and when the service stops/fails a Sev 2 TT is generated for a particular team ?

1711


What is option in shell script?

556


What is in a script?

562