View difference between Paste ID: xYDBHdRH and VMW2HjHi
SHOW: | | - or go back to the newest paste.
1
#!/bin/sh
2
printf "Enter a number\n"
3
read c
4
x=$c
5
s=0
6
while [ $x -gt 0 ]
7
do
8-
	r=`expr $x % 10`
8+
	s=(( s + x % 10 * x % 10 * x % 10 ))
9-
	s=`expr $s + $r * $r * $r`
9+
10
done
11
if [ $s -eq $c ]
12
	then
13
		echo "It is an armstrong number"
14
	else
15
		echo "It is not an armstrong number"
16
fi