Advertisement
achshar

Untitled

Jan 28th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. s=(( s + x % 10 * x % 10 * x % 10 ))
  9. x=`expr $x / 10`
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement