login
A070871
a(n) = A002487(n) * A002487(n+1) (Conway's alimentary function).
11
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, 24, 21, 28, 20, 5, 6, 30, 45, 36, 44, 77, 70, 30, 33, 88, 104, 65, 60, 84, 63, 18, 18, 63, 84, 60, 65, 104, 88, 33, 30, 70, 77, 44, 36, 45, 30, 6, 7, 42, 66
OFFSET
1,2
COMMENTS
Irregular triangle read by rows. The n-th row, containing 2^(n-1) elements, consists of the reciprocals of the first differences of the sequence formed by combining the first n levels of the Stern-Brocot tree, that is, the reciprocals of the first differences of A049455(n,k) / A049456(n,k) for k = 0, .., 2^(n-1). - William P. Orrick, Apr 25 2026
LINKS
Robert G. Wilson v, Plot of first 4096 terms
FORMULA
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).
Sum of the n-th row equals A052913(n-1). - William P. Orrick, Apr 25 2026
Apart from c = 0, the entries in column c grow quadratically. The k-th entry in column c > 0, where k = 1 indexes the first appearance of an entry in that column, is given by a(c) * (k+1) * (k+2) - a(c+2^(floor(log_2(c)))) * (k+1) + a(c-2^(floor(log_2(c)))) * (k+2). The k-th entry in column 0 is k. - William P. Orrick, Apr 28 2026
EXAMPLE
From William P. Orrick, Apr 25 2026: (Start)
Array begins
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, 24, 21, 28, 20, 5;
...
n = 3. The elements of the Stern-Brocot tree up to the third level, in left to right order, are 0/1, 1/3, 1/2, 2/3, 1/1. The first differences are 1/3, 1/6, 1/6, 1/3, whose reciprocals are 3, 6, 6, 3. (End)
MAPLE
b:= proc(n) option remember; `if`(n<2, n,
(q-> b(q)+(n-2*q)*b(n-q))(iquo(n, 2)))
end:
a:= n-> b(n)*b(n+1):
seq(a(n), n=1..100); # Alois P. Heinz, Feb 11 2021
MATHEMATICA
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}]
PROG
(Python)
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)
def a(n): return a002487(n)*a002487(n + 1) # Indranil Ghosh, Jun 08 2017
(Python)
from functools import reduce
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
(PARI) a(n)= my(t=[0, 1]); foreach(binary(n), b, t[2-b]+=t[2-!b]); t[1]*t[2]; \\ Ruud H.G. van Tol, Apr 26 2026
(SageMath)
def A070871(n):
curN = Integer(n)
indList = []
rNext = curN.nbits()
while curN > 0:
r = rNext
c = curN - 2^(r-1)
if c > 0:
rNext = c.nbits()
j = r - rNext
indList.append(j)
else:
co2 = r
co1 = co2 + 1
co0 = 0
curN = c
for i in range(len(indList)-1, -1, -1):
j = indList[i]
newCo2 = co2 * (j+1) * (j+2) - co1 * (j+1) + co0 * (j+2)
newCo1 = newCo2 + co2 * (2*j+4) - co1 + co0
co0 = co2
co2 = newCo2
co1 = newCo1
return(co2) # William P. Orrick, Apr 28 2026
CROSSREFS
Sequences related to iterating the map n -> a(n): A071884, A071885, A071886, A071887.
Sequence in context: A132886 A119272 A308483 * A096115 A289838 A290734
KEYWORD
nonn,tabf,easy,look
AUTHOR
N. J. A. Sloane, May 19 2002
STATUS
approved