Could you please provide the exact instructions/requirements?
But i also need to fulfill to goal that 50% of my answers of n less than or equal to 10^6. WHat does that mean and how can I achieve that?
This means nothing.
"50% of my answers of n less than or equal to 106 [does something/have some characteristics]". We need to know what this 50% should do, and what requirements they should fulfill.
Unless... you mean that "50% of my answers of n ARE less than or equal to 106", meaning that you need to list all the number of digits counter from 1 to X, where X ranges from 1 to n, and 50% of your digit counts must be less than 106 and the other 50% higher than 106.
So the following table would list the numbers and number of lines in the green section is the same as the number of lines in the orange section.
| x (from 1 to n) | numbers from 1 to x | number of digits |
|---|
| 1 | 1 | 1 |
| 2 | 12 | 2 |
| 3 | 123 | 3 |
| ... | 123... | ... |
| ? - 1 | 123...(?-1) | 999,999 |
| ? | 132...? | 1,000,000 |
| ? + 1 | 123...(?-1)?(?+1) | 1,000,001 |
| ... | 123... | ... |
| END | 123...(?-1)?(?+1)...END | END_COUNT |
The best option is to check your requirements again.