Saturday, August 26, 2017

#2: Sequence Of Powers

Let's take a look at this infinite sequence of powers of ten, starting with the number 1.

110100100010000....

Your task is to write a program that would print the digit in a given position and the digit in the position right next to it. The program should be written to find the digits within a second even with an input integer of 1 000 000 (which means that you would need to look at the millionth digit to print it out).

Example:
Input: 7
Output: 1 0

Explanation: On position 7 and 8 in the sequence (110100100010000...) there are 1 and 0 as digits.

No comments:

Post a Comment