Number of Digit One

Hard · Math & Number Theory · about 30 minutes

Asked at Google, Amazon, Microsoft, Salesforce, Bloomberg.

Write out every integer from 0 up to n and count how many times the digit 1 shows up in total.