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
How do I run a script on mac?
How does ls command work?
What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?
What will happen to my current process when I execute a command using exec?
Why do we use shell scripting?
What is a file basename?
How to print pid of the current shell?
What is bash shell command?
What is the use of .sh file?
What is c in shell script?
How to get script name inside a script?
What is a batch file used for?
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 ?
What is option in shell script?
What is in a script?