SmartGenius

Factorial Calculation in Batch

Jul 6th, 2012
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. ::Created By Guerrerohgp
  4. :ini
  5. set result=1
  6. set/p "num=Ingrese su numero: "
  7. if not defined num goto:ini
  8. call:Function_factorial !num!
  9. echo.El factorial de !num! es !result!
  10. pause>nul
  11. exit
  12.  
  13. :Function_factorial
  14. if %1==1 goto:eof
  15. set/a "result*=%1"
  16. set/a "n=%1-1"
  17. call:Function_factorial !n!
Advertisement
Add Comment
Please, Sign In to add comment