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