login
a(n) = A002487(n) * A002487(n+1) (Conway's alimentary function).
10

%I #18 May 05 2023 12:30:37

%S 1,2,2,3,6,6,3,4,12,15,10,10,15,12,4,5,20,28,21,24,40,35,14,14,35,40,

%T 24,21,28,20,5,6,30,45,36,44,77,70,30,33,88,104,65,60,84,63,18,18,63,

%U 84,60,65,104,88,33,30,70,77,44,36,45,30,6,7,42,66

%N a(n) = A002487(n) * A002487(n+1) (Conway's alimentary function).

%H Indranil Ghosh, <a href="/A070871/b070871.txt">Table of n, a(n) for n = 1..16384</a>

%H Robert G. Wilson v, <a href="/A070871/a070871.jpg">Plot of first 4096 terms</a>

%F Sum of reciprocals of k-th "chunk" (between two entries k) = 1 (for example for the third chunk, 1/3 + 1/6 + 1/6 + 1/3 = 1).

%p b:= proc(n) option remember; `if`(n<2, n,

%p (q-> b(q)+(n-2*q)*b(n-q))(iquo(n, 2)))

%p end:

%p a:= n-> b(n)*b(n+1):

%p seq(a(n), n=1..100); # _Alois P. Heinz_, Feb 11 2021

%t a[0] = 1; a[n_] := If[ OddQ[n], a[n/2 - 1/2], a[n/2] + a[n/2 - 1]]; Table[ a[n - 1]*a[n], {n, 1, 70}]

%o (Python)

%o def a002487(n): return n if n<2 else a002487(n/2) if n%2==0 else a002487((n - 1)/2) + a002487((n + 1)/2)

%o def a(n): return a002487(n)*a002487(n + 1) # _Indranil Ghosh_, Jun 08 2017

%o (Python)

%o from functools import reduce

%o def A070871(n): return sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(n)[-1:2:-1],(1,0)))*sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(n+1)[-1:2:-1],(1,0))) # _Chai Wah Wu_, May 05 2023

%Y Cf. A002487, A070872-A070874.

%K nonn

%O 1,2

%A _N. J. A. Sloane_, May 19 2002