All odd numbers from 51 to 5001 are written [closed]

All odd numbers from 51 to 5001 are written. What is total number of digits used?

• Why downvote??? Oct 23, 2020 at 17:38
• This doesn't really seem like a puzzle. It seems like a fairly trivial math problem. Oct 23, 2020 at 17:44
• I think there's a twist to it that makes it legit. Oct 23, 2020 at 17:47
• If you want to ask a new question, ask a new question. Don't edit over an old already-answered puzzle. Dec 22, 2020 at 23:33
• I can’t this account is not longer accepting questions, tried to fix the probs for other questions, but there is not any thing I could fix... Dec 24, 2020 at 3:13

10. That is, the digits 0 through 9

BUT:

If this is the correct answer, the question should be relentlessly downvoted. If you're trying to trip people up with intricacies of the English language, then everything about the question must be absolutely perfect.

• Relevant XKCD: xkcd.com/169 Oct 23, 2020 at 19:42
• @Voldemort'sWrath There really is an xkcd for everything Oct 23, 2020 at 20:08
• @TrojanByAccident -- There truly is! :):) Oct 23, 2020 at 20:09

Just noticed a discrepancy in the title and the body. Based on the title: There are

18,806 total digits

Logic:

From 51-99 there are 49 2 digit numbers. Then 900 3 digit numbers, then from 1,000-5,001 there are 4,002 4 digit numbers. Multiply together 49 x 2 + 900 x 3 + 4,002 x 4 to get the total count.

Based on the body (odd numbers only) it becomes:

25 x 2 + 450 x 3 + 2,001 x 4 = 9,404 digits

• question said ODD numbers. But your approach is sound. Oct 23, 2020 at 17:51
• @ChrisCudmore Yeah, I just noticed that, I was going based on the title, missed that the body was slightly different. Added both answers Oct 23, 2020 at 17:53

None. The letters are written out in letters.

Use a python code:

print(len(''.join([str(i) for i in range(51, 5002) if i%2])))

Output:

9404

Explanation:

Let me break it down:

If I do numbers = [i for i in range(1, 10)], python will interpret it as numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]. The last number is omitted, hence in my code I used range(51, 5002).

Python won't let us count the digits of numbers in a practical way, so I convert them into strings with str().

if i % 2 means if the number divided by two is not zero.

Now we have a list of all the odd numbers in strings, time to find the length. Instead of summing up the length of each number, we can connect all the strings into one large string, and then find the length of that single string. ''.join() does the trick.

Finally, I use len() to find the length of that large string and print the result.

Looping over each and every number might not be practical, but hey, it's easier to understand, right?