Modify PRIMCOB1 to work with gnuCOBOL

I ported the PRIMCOB1 (Sieve of Eratosthenes) COBOL program included with MVS 3.8j in the TK4- package to gnuCOBOL V3. The old COBOL program can generate prime numbers up to 32767. The gnuCOBOL version doesn’t have that limitation, and I modified it to generate primes up to one million.

One of the reasons I did this is because I was watching a YouTube video titled “The Worst Programming Language Ever – Mark Rendle – NDC Oslo 2021” and of course the first language he mentioned was COBOL. As one of the very first compiled languages, isn’t it strange that it wasn’t near perfect? It had so many other languages to look to for better ideas. Right? Wrong! And he said they benchmarked another terrible language doing the Sieve of Eratosthenes and it took 17 hrs. Compared to a FORTRAN program that took .5 sec. Now I don’t know how long ago this was, but Fortran (Formula Translator) is a math programming language. So you would expect it to do good. But little 60+ year old business language, COBOL (Common Business Oriented Language) also doing it in less than a second is pretty cool…I think.

It generated these in less than a second. Here are the last few lines using the Linux time command…

999091 999101 999133 999149 999169 999181 999199 999217 999221 999233 999239 999269 999287 999307 999329 999331 999359 999371 999377 999389
999431 999433 999437 999451 999491 999499 999521 999529 999541 999553 999563 999599 999611 999613 999623 999631 999653 999667 999671 999683
999721 999727 999749 999763 999769 999773 999809 999853 999863 999883 999907 999917 999931 999953 999959 999961 999979 999983

78498 primes up to 1000000 found.

real 0m0.193s
user 0m0.146s
sys 0m0.000s