Skip to content

Instantly share code, notes, and snippets.

@ghais
Created December 11, 2012 20:39
Show Gist options
  • Save ghais/4261946 to your computer and use it in GitHub Desktop.
Save ghais/4261946 to your computer and use it in GitHub Desktop.
Develop a program that generates in ascending order the least 100 numbers of the set M, where M is defined as follows:
a) The number 1 is in M.
b) If x is in M, then y = 2 * x + 1 and z = 3 * x + 1 are also in M.
c) No other numbers are in M.
Wirth also gives the first six numbers in the result sequence: 1, 3, 4, 7, 9, 10….
Your task is to write a program that finds the first n numbers in Wirth’s sequence, and use it to solve Wirth’s exercise. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment