# I really Need a help!

For every real positive integer $$n$$, define $$f(n)$$ as the number of $$1$$'s that appear(s) in the decimal representation of all positive integer numbers from $$1$$ to $$n$$. For example, $$f(6) =1$$ and $$f(16) = 9$$. Prove that $$f(10^n) = n(10^{n-1}) + 1$$ for all positive integer $$n$$.

Note by Fidel Simanjuntak
3 years, 9 months ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

There is a simple combinatorial argument for this.

Notice that $f(n)=k+f(n-1)$ where $k$ is the number of 1s in $n$. Now, we have only a single 1 in powers of 10, so $f(10^n)=f(10^n-1)+1$. Now, all numbers $\leq 10^n-1$ are at most $n$ digit numbers (can be thought of as $n$ digit numbers using non negative digits). Now, we need to count the numbers having 1 in their digits. Fixing 1 at one of the digits places is done in $n$ ways and the other $n-1$ digit places can be assigned a digit from 0 to 9 in 10 ways for each digit place, hence $10^{n-1}$ ways. Notice that there's no problem with excessive counting or missing out on counting a few since if a number has $m$ 1s, it is counted exactly once for fixing 1 at each of the $m$ digit places, thus it getting counted exactly $m$ times as desired. Now then, by the rule of product, we have $f(10^n-1)=n10^{n-1}$ and hence we conclude that,

$f(10^n)=n\cdot 10^{n-1}+1$

- 3 years, 9 months ago

Can you give a proof for $f(n) = k + f(n-1)$? I still don't get it..

- 3 years, 9 months ago

If $f(n)$ is the number of 1s in the numbers from 1 to $n$, then this is equivalent to the number of 1s in the numbers from 1 to $n-1$ plus the number of 1s in $n$, right? Denoting by $k$ the number of 1s in $n$, we can write $f(n)=k+f(n-1)$.

- 3 years, 9 months ago

What do you mean, by saying "fixing" ?

- 3 years, 9 months ago

By "fixing", I mean specifying one of the digit places to be 1 (hence making the digit place fixed) and letting the other digit places vary.

Such "fixing" argument tend to be common in counting (enumeration) problems.

- 3 years, 9 months ago

I'm sorry for bothering you, but I still don't get this " Notice that there's no problem with excessive counting or ........". Can you help me?

- 3 years, 9 months ago

That part was to show that if a number has $m$ 1s, it is getting counting exactly $m$ times, no more no less. This is because we want to count the number of occurrences of 1s for that number, which is $m$.

And don't worry, if you have any further problems understanding my solution, feel free to ask. I'll try my best to help you understand. After all, a solution is no good if it can't be completely understood by the reader. ;)

PS: I'm typing from my mobile, so I might be late responding to your queries, sorry for that.

- 3 years, 9 months ago

What do you mean, by saying "fixing" ?

- 3 years, 9 months ago