home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / misc_programming / batnmore.z!p / FIBONACC.BTM < prev    next >
Text File  |  1992-11-15  |  835b  |  27 lines

  1. *REM This batch file is Freeware, free to use and redistribute unmodified *
  2. *REM Jouni Miettunen * jon@stekt.oulu.fi * Oulu * Finland * Europe * 1992 *
  3.  
  4. REM This calculates the first 76 Fibonacci numbers F(n) = F(n-1) + F(n-2)
  5. REM Timestamp 15-Nov-1992
  6.  
  7. break on^setlocal^unalias *^unset *
  8. set a=0^set b=1
  9.  
  10. :loop
  11. set c=%b^set b=%a^set a=%@eval[%b+%c]^set index=%@eval[%index+1]
  12.  
  13. REM just trying to create a decent output
  14. screen %_row 0 Fibonacci(
  15. screen %_row %@eval[12-%@len[%index]] %index):
  16. screen %_row %@eval[36-%@len[%a]-%@int[%@eval[%@len[%a]/3]]]]
  17. set plaza=%@eval[%@len[%a]%%3]
  18. echos %@substr[%a,,%plaza]
  19. for %q in (0 3 6 9 12) echos ` `%@substr[%a,%@eval[%plaza+%q],3]
  20. echo.
  21.  
  22. REM Can't calculate beyond 76th Fibonacci number, see FIBOS255.BTM for more
  23. if %index lt 76 goto loop
  24.  
  25. :end
  26. break off^quit
  27.