Qm
BrainteasersJane StreetCitadel

The nine-digit number whose every prefix divides

Find a nine-digit number that uses each of the digits 1 to 9 exactly once, such that:

  • its first digit is divisible by 1,
  • its first two digits form a number divisible by 2,
  • its first three digits form a number divisible by 3,
  • and so on, up to the whole nine-digit number being divisible by 9.

Find it, and show how the divisibility rules cut the search down to almost nothing.

Show a hint

Even positions (2nd, 4th, 6th, 8th) must hold even digits, so the odd positions hold the odd digits. The fifth digit must be 5. Then use the rules for 4 and 8, which depend only on the last two or three digits of each prefix, and the rule for 3.

Your answer

Solving needs a free account

Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

The number equal to the sum of the cubes of its digitsThe number that equals the sum of the factorials of its digitsThe two-digit number that is the square of its digit sumThe number that rotates when multipliedA quick test for divisibility by 7
All questions →