GL1TCH3D

Icarus Challenge 3 - fibonacci

Jan 18th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. @echo off
  2. title Icarus Challenge 3 - Fibonacci Sequence
  3. setlocal enabledelayedexpansion
  4.  
  5. :top
  6. set/p steps=How many steps of the fibonacci sequence would you like to calculate?
  7. set steps=!steps: =!
  8. if not 0 lss %steps% cls&goto top
  9.  
  10. set step0=0
  11. set step1=1
  12. set num=2
  13. set all=0
  14.  
  15. :loop
  16. if %num% equ %steps% goto end
  17. set /a temp1=%num% - 1
  18. set /a temp2=%num% - 2
  19. set /a step%num%= !step%temp1%! + !step%temp2%!
  20. echo !step%temp2%! + !step%temp1%! = !step%num%!
  21. set /a num+=1
  22. goto loop
  23.  
  24. :end
  25. for /l %%b in (1,1,%num%) do (
  26. set all=!all!, !step%%b!
  27. )
  28. echo.
  29. echo The numbers in a list:
  30. echo %all%
  31. pause > nul
Advertisement
Add Comment
Please, Sign In to add comment