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

What are the four fundamental components of every file system on linux?

0 Answers  


Can you write a script to portray how set –x works?

0 Answers  


What is Path variable?What is its use?

1 Answers  


How to find all the files modified in less than 3 days and save the record in a text file?

0 Answers  


What is path in shell script?

0 Answers  


What does sh mean?

0 Answers  


How to open a read-only file in the shell?

0 Answers  


How to group the commands in shell scripting?

2 Answers   Polaris,


What is the command for " how many shell is running in your system or how many shell supported by your system " ?.

3 Answers  


What is scripting autism?

0 Answers  


What is the equivalent of a file shortcut that we have a window on a linux system?

0 Answers  


What are the different kinds of loops available in shell script?

3 Answers  


Categories