data/problems/384.yml
---
:id: 384
:name: Rudin-Shapiro sequence
:url: https://projecteuler.net/problem=384
:content: "Define the sequence a(n) as the number of adjacent pairs of ones in the
binary expansion of n (possibly overlapping). \nE.g.: a(5) = a(101<sub>2</sub>)
= 0, a(6) = a(110<sub>2</sub>) = 1, a(7) = a(111<sub>2</sub>) = 2\n\nDefine the
sequence b(n) = (-1)<sup>a(n)</sup>. \nThis sequence is called the **Rudin-Shapiro**
sequence.\n\nAlso consider the summatory sequence of b(n): ![p384_formula.gif]({{
images_dir }}/p384_formula.gif).\n\nThe first couple of values of these sequences
are: \n<tt>n 0 1 2 3 4 5 6 7\n<br>a(n) 0
0 0 1 0 0 1 2\n<br>b(n) 1 1 1 -1
1 1 -1 1\n<br>s(n) 1 2 3 2 3 4 3 4</tt>\n\nThe
sequence s(n) has the remarkable property that all elements are positive and every
positive integer k occurs exactly k times.\n\nDefine g(t,c), with 1 ≤ c ≤ t, as
the index in s(n) for which t occurs for the c'th time in s(n). \nE.g.: g(3,3)
= 6, g(4,2) = 7 and g(54321,12345) = 1220847710.\n\nLet F(n) be the fibonacci sequence
defined by: \nF(0)=F(1)=1 and \nF(n)=F(n-1)+F(n-2) for n\\>1.\n\nDefine GF(t)=g(F(t),F(t-1)).\n\nFind
ΣGF(t) for 2≤t≤45.\n\n"