Try it yourself

Share a quote, a general thought, jokes or one liners here.
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Try it yourself

Post by zprogrammer »

Technical puzzle

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
zprogrammer
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Try it yourself

Post by zprogrammer »

Got to break my fingers before posting next time :mrgreen:
zprogrammer
Post Reply Previous topicNext topic

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Thought of the Day, General Talk & Jokes.”