Below code in REXX generates prime numbers present between 1 to 1000.
Try to solve the same puzzle in Cobol.If you are able to solve in Cobol try a different language.
See how many languages you could solve the below problem
Code: Select all
/*REXX*/
DO Y = 1000 TO 1 BY -1
N = 0
DO X = 1 TO 1000 BY +1
Z = INDEX(Y/X,'.')
IF Z = 0 THEN DO
N = N+1
Y = RIGHT(Y,4)
END
END
IF N<=2 THEN DO
SAY Y 'IS A PRIME NUMBER'
END
END