tampurus

4 factorial of number

Dec 7th, 2021
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.41 KB | None | 0 0
  1. # ************While****************
  2. echo enter the number
  3. read n
  4. i=1
  5. fact=1
  6. while [ $i -le $n ]
  7. do
  8.     fact=`expr $fact \* $i`
  9.     i=`expr $i + 1`
  10. done
  11. echo factrial is $fact
  12.  
  13. # ************Until*******************
  14. echo enter the number
  15. read n
  16. fact=1
  17. i=1
  18. until [ $i -gt $n ]
  19. do
  20.     fact=`expr $fact \* $i`
  21.     i=`expr $i + 1`
  22. done
  23. echo factrial is $fact
  24.  
  25. # ***************For*******************
  26.  
Advertisement
Add Comment
Please, Sign In to add comment