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 additional egrep symbols?

2 Answers  


Hi Friends, I am currently Undergoing Course On Testing.I am Planning To Keep Fake Resume.Can any One tell me the ways to Prepare i.e, Real Time experience For Manual Testing. With Regards, Vikram

1 Answers  


How do I start a shell script?

0 Answers  


What is awk in shell script?

0 Answers  


Write a shell program to test whether a given number is even or odd?

8 Answers  






if i have 2 files file1 and file2.... file1 contains 2 columns like b a 11 aa 12 as 13 ad 15 ag 11 ar 13 ah 15 ak file2 contains b c 10 ds 11 at 15 gh 15 jk 13 iu 11 fg 13 yy can any 1 give me the program to display in this way? a b c aa 11 at ar 11 fg ad 13 iu ah 13 yy ag 15 gh ak 15 jk

3 Answers  


What are filters explain sort with all the options available?

0 Answers  


What are the different types of variables used in shell script?

0 Answers  


How to print pid of the current shell?

0 Answers  


What can you do with powershell?

0 Answers  


Create a bash shell script that removes all files whose names end with a "~" from your home directory and subdirectories. Name this script "cleanup.sh"

6 Answers  


How to get the last line from a file using just the terminal?

0 Answers  


Categories