%I #41 Dec 17 2019 08:08:30
%S 1,0,1,0,1,1,1,0,1,1,2,1,2,1,1,0,1,1,2,1,3,1,3,1,3,1,3,1,2,1,1,0,1,1,
%T 2,1,3,1,3,1,4,4,4,1,4,4,4,1,4,4,4,1,4,4,4,1,3,1,3,1,2,1,1,0,1,1,2,1,
%U 3,1,3,1,4,4,4,1,4,4,4,1,5,2,8,2,8,2,5,1,5,2,8,2,8,2,5,1,5,2,8,2
%N a(0) = 1 & a(1) = 0; for n > 0, a(2n) = a(n) + a(n-1); if a(n) is even then a(2n+1) = a(n)/2, but if a(n) is odd then a(2n+1) = (3a(n)-1)/2
%C Each of the even-indexed numbers in the sequence is the sum of two adjacent terms (taken from the formula for the Fibonacci sequence), while each of the odd-indexed numbers is the result of a single iteration of the function similar to the Collatz function; so I call a sequence like this a "Colla-nacci" sequence. When the sequence is graphed, one can see that it contains a fractal pattern of perfectly symmetric subsequences resembling cathedrals or a city-scape.
%H Daniel Godzieba, <a href="/A322305/b322305.txt">Table of n, a(n) for n = 0..65535</a>
%t a[0] = 1; a[1] = 0; a[n_] := a[n] = If[EvenQ[n], a[n/2] + a[n/2 - 1], If[EvenQ[ a[(n - 1)/2]], a[(n - 1)/2]/2, (3*a[(n - 1)/2] - 1)/2]]; Array[a, 100, 0] (* _Amiram Eldar_, Aug 29 2019 *)
%o (Python)
%o import numpy as np
%o s = np.array([1,0])
%o for i in range(1,1000):
%o ....s = np.append(s, s[i] + s[i-1])
%o ....if s[i]%2==0:
%o ........s = np.append(s, s[i]//2)
%o ....else:
%o ........s = np.append(s, (3*s[i]-1)//2)
%K easy,nonn,look
%O 0,11
%A _Daniel Godzieba_, Aug 28 2019
|