Editorial
There are 9 single-digit numbers: from 1 to 9.
There are 90 two-digit numbers: from 10 to 99.
There are 900 three-digit numbers: from 100 to 999.
The number of -digit natural numbers equals . At , the answer equals , for which the data type long long
should be used.
Implementation of the algorithm
Read the input value .
scanf("%d", &n);
Calculate the answer in the variable res
, equal to .
res = 9; for (i = 1; i < n; i++) res *= 10;
Output the answer.
printf("%lld\n", res);