Loading Now

firstOccurrenceOfNumber

A sequence of digits is obtained by writing down decimal representations of all integers starting with 1 and continuing up to a certain number Nconsecutively. Here’s how the sequence begins:
12345678910111213141516171819202122 ...

Write a program that will compute the 1-based position of the first occurrence of the decimal representation of number in the sequence.

Example:

For n=12 the output should be firstOccurrenceOfNumber(n) = 1 because the first position of number 12 in the sequence is one

Input/Output:

  • [execution time limit] 0.5 seconds 

  • [input] integer N

    1 ≤ N ≤ 1000

  • [output] integer

    The position of the first occurrence of the decimal representation of number N in the sequence.

Post Comment

Contact