Skip to content

Instantly share code, notes, and snippets.

@lperrin
Last active February 18, 2017 01:15
Show Gist options
  • Save lperrin/a5ea68fb0d5f8f97ba0e to your computer and use it in GitHub Desktop.
Save lperrin/a5ea68fb0d5f8f97ba0e to your computer and use it in GitHub Desktop.
Find the magic number

Find the magic number

The goal is to find the smallest number (let's call it M) such that:

  • If M obeys property X, then the digit X is part of the number.
  • If M does not obey property X, then the digit X is NOT part of the number.

For example, if 2457 were a magic number, it would obey properties 2, 4, 5, 7 and not 0, 1, 3, 6, 8, 9. However we find that not to be the case, so it is not the number we are looking for.

Properties

  • 0. One of the digits of M is the sum of the others.
  • 1. Digits in decreasing sequence.
  • 2. M has at least 2 odd digits.
  • 3. All digits are different.
  • 4. There is no subset in the digits with a sum of 4.
  • 5. The number is not a palindrome.
  • 6. The number does not contain 3 odd digits in a row.
  • 7. M is a prime number.
  • 8. M has at least 2 even digits in a row.
  • 9. The product of all odd digits is a square number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment