Write a shell script to check whether a number is Armstrong number or not?



Write a shell script to check whether a number is Armstrong number or not?..

Answer / 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

More Shell Script Interview Questions

how did u debugging in unix/ linux platform ??( project Related)

2 Answers   Symphony,


Is shell a scripting language?

0 Answers  


write a shell script to check whether all the directories in the path exist has read and write permission

1 Answers  


What is a file basename?

0 Answers  


What are the different methods available to run a shell script?

2 Answers  






What is the use of break command?

0 Answers  


I have to write Shells (Linux + Unix)for publishing packages and reports. Is it possible ? What are the differents executable programs ineed to call ?

0 Answers  


I want to connect to a remote server and execute some commands, how can I achieve this?

0 Answers  


How do I set bash as default shell mac?

0 Answers  


What are the different types of shell scripting?

0 Answers  


is this growing field and what is average package in this?

0 Answers  


What is basename in shell script?

0 Answers  


Categories