No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Suite de Fibonacci

Description du code

Code source ou contenu du fichier

  1. IDENTIFICATION DIVISION.
  2. PROGRAM-ID. FIBONACCI.
  3.  
  4. ENVIRONMENT DIVISION.
  5. DATA DIVISION.
  6.  
  7. WORKING-STORAGE SECTION.
  8. 77 N PIC 9(18).
  9. 77 N1 PIC Z(18).
  10. 77 M PIC 9(18) VALUE 1.
  11. 77 O PIC 9(18).
  12. 77 I PIC 9(4) VALUE 1.
  13. 77 Q PIC X.
  14.  
  15. PROCEDURE DIVISION.
  16. PARA-A.
  17. DISPLAY ( 1 , 1 ) ERASE.
  18. DISPLAY ( 2 , 1 ) "FIBONACCI NUMBERS FROM 1 TO 100 ARE:".
  19. MOVE 0 TO N.
  20. DISPLAY " ".
  21. DISPLAY 0.
  22. DISPLAY 1.
  23. MOVE 0 TO O.
  24.  
  25. PARA-B.
  26. COMPUTE N = O + M.
  27. MOVE N TO N1.
  28. MOVE M TO O.
  29. MOVE N TO M.
  30. DISPLAY N1.
  31. ADD 1 TO I.
  32. IF I = 21
  33. DISPLAY "PRESS TAB KEY TO VIEW NEXT PAGE."
  34. ACCEPT Q.
  35. IF I = 41
  36. DISPLAY "PRESS TAB KEY TO VIEW NEXT PAGE."
  37. ACCEPT Q.
  38. IF I = 61
  39. DISPLAY "PRESS TAB KEY TO VIEW NEXT PAGE."
  40. ACCEPT Q.
  41. IF I = 81
  42. DISPLAY "PRESS TAB KEY TO VIEW NEXT PAGE."
  43. ACCEPT Q
  44. IF I = 99
  45. GO TO STOP-PARA
  46. ELSE
  47. GO TO PARA-B.
  48. STOP-PARA.
  49. DISPLAY " ".
  50. STOP RUN.

Autres extraits de codes en cobol

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 05/10/2009, last modified the 28/10/2018
Source of the printed document:https://www.gaudry.be/en/sniplet-rf-cobol/fibonacci-iter.cob.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.