XeBuZer0

Fibonacci's secuence in Cobol (iterative)

Dec 21st, 2019
794
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  2.       * PROGRAMA QUE CALCULA LA SUCESIÓN DE FIBONACCI. CALCULA SIN *
  3.       * PROBLEMAS HASTA EL 183. PUEDE QUE PARA NÚMEROS MÁS GRANDES *
  4.       * SE TENGA QUE UTILIZAR OTRO COMPILADOR DISTINTO A GNUCOBOL. *
  5.       * LICENCIADO BAJO GNU GENERAL PUBLIC LICENCE (GNU GPL) 3.0  *
  6.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  7.        IDENTIFICATION DIVISION.
  8.        PROGRAM-ID. XBZ0-FIB.
  9.        AUTHOR JESUS GUSTAVO VARGAS PEREZ (XEBUZER0).
  10.        INSTALLATION EN TU KORA :V .
  11.        DATE-WRITTEN 21-DICIEMBRE-2019.
  12.        DATE-COMPILED 21-DICIEMBRE-2019.
  13.        REMARKS #AlChile soy la mera v3rdur4 prr05 #DoNotDisturb #DnD
  14.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  15.        ENVIRONMENT DIVISION.
  16.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  17.        DATA DIVISION.
  18.             WORKING-STORAGE SECTION.
  19.                 01 WS-TIMES      PIC 9(38) VALUE 1.
  20.                 01 WS-ACUM       PIC 9(38) VALUE 1.
  21.                 01 WS-CONT       PIC 9(38) VALUE 1.
  22.                 01 FIBONUMS.
  23.                     02 FIBOPRIM  PIC 9(38) VALUE ZEROS.
  24.                     02 FIBOSEGU  PIC 9(38) VALUE 1.
  25.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  26.        PROCEDURE DIVISION.
  27.        000-PRINCIPAL.
  28.             PERFORM 100-LEER-NUM.
  29.             PERFORM 200-FIBONACCI.
  30.             PERFORM 300-SALIR.
  31.        000-EXIT.
  32.        EXIT.
  33.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  34.        005-SANITIZAR.
  35.             IF WS-TIMES < 0 THEN
  36.                 MULTIPLY WS-TIMES BY -1 GIVING WS-TIMES.
  37.        005-EXIT.
  38.        EXIT.
  39.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  40.        100-LEER-NUM.
  41.             DISPLAY "INGRESE NÚMERO NATURAL".
  42.             ACCEPT WS-TIMES.
  43.             005-SANITIZAR.
  44.        100-EXIT.
  45.        EXIT.
  46.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  47.        200-FIBONACCI.
  48.             PERFORM 250-FIBOCICLO
  49.                 VARYING WS-CONT FROM 1 BY 1
  50.                     UNTIL WS-CONT = WS-TIMES.
  51.             DISPLAY "EL NÚMERO DE FIBONACCI ES: " WS-ACUM.
  52.        200-EXIT.
  53.        EXIT.
  54.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  55.        250-FIBOCICLO.
  56.             ADD  FIBOPRIM TO FIBOSEGU GIVING WS-ACUM.
  57.             MOVE FIBOSEGU TO FIBOPRIM.
  58.             MOVE WS-ACUM  TO FIBOSEGU.
  59.        250-EXIT.
  60.        EXIT.
  61.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
  62.        300-SALIR.
  63.             STOP RUN.
  64.        300-EXIT.
  65.        EXIT.
  66.       ***C**** ***O**** ***M**** ***M**** ***E**** ***N**** ***T****
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×