I have this task where I need to get 5 numbers in binary array, but i cant think of way to generate it. The building process is:
Starts Width 10 then adds same number but 1 and 0 are switched places like this
10
10 + 01
1001 + 0110
10010110 + 01101001
1001011001101001 + 0110100110010110
...
I can't figure out mathematical way to generate it
I need to get digits in positions n, n+1, n+2, n+3, n+4 where n <= 10^9
REMEMBER THIS ISN'T SCHOOL TASK it's task from old Olympiad witch I'm doing to understand tasks concept and learning for next one
Symbol array 1001011001101001... makes so - first is written 1 then last part of array writes at the end of existing one only changing 1 to 0 and 0 to 1 like this 1 → 10 → 1001 → 10010110 → ...
Task: Write programm, that any given integer n in this array finds n, n+1, n+2, n+3 and n+ 4 symbol!
This is the complement of the Thue-Morse sequence. To get the digit in position $n$, express $n-1$ (assuming you count from $1$) in binary and count the number of $1$ bits. If the number of $1$'s is odd, your entry is zero, while if the number of $1$'s is even the entry is $1$.