Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Cobol/verschiedene-Autoren/Jens/   (verschiedene Autoren Version 0.7©)  Datei vom 4.1.2008 mit Größe 1 kB image not shown  

Quelle  collatz.cob   Sprache: Cobol

 

       identification division.
       program-id. collatz.
      * das Collatz-Problem aus Wikipedia
      * auch als Ulam-Problem bekannt
      * und aus Mäder "Mathematik für ..."
       author. "JD".
       date-written. 22.9.2006.
       date-compiled.
       data division.
       working-storage section.
         77 m   pic 9(4).
         77 k   pic 9(4).
       linkage section.
         77 n   pic 9(4).
       procedure division using n.
         evaluate function mod(n,4)
         when 0 
           divide 4 into n
         when 1
           compute n = 3*n+1
           evaluate function mod(n,4)
           when 0
             divide 4 into n
           when 1
             compute n = 3*n+1
             evaluate function mod(n,4)
             when 0
               divide 4 into n
             when 1
               compute n = 3*n+1
             when 2
               divide 2 into n
             when 3
               compute n = 3*n+1
            end-evaluate  
           when 2
             divide 2 into n
           when 3
             compute n = 3*n+1
           end-evaluate
         when 2
           divide 2 into n
         when 3
             compute n = 3*n+1
             evaluate function mod(n,4)
             when 0
               divide 4 into n
             when 1
               compute n = 3*n+1
             when 2
               divide 2 into n
             when 3
               compute n = 3*n+1
            end-evaluate  
         end-evaluate  
         display "done".
         stop run.
        end-program collatz.

Messung
CHZG
919910096

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-25) ¤

*© Formatika GbR, Deutschland