Qm

How many times is the digit 7 written from 1 to 1000?

You write out every whole number from 1 to 1000.

How many times do you write the digit 7? (The number 777 counts three times, since it contains three 7s.)

Then a follow-up: how many of the numbers from 1 to 1000 contain at least one 7?

Show a hint

Think of the numbers 000 to 999 as three-digit strings. In each position, how often does a 7 appear?

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 book that took 792 digits to numberThe sum of all digits from 1 to a millionHow many times is the digit 1 written from 1 to 1000?Palindromic dates in the 2020sAdd up every digit from 1 to 999
All questions →