%I #33 Dec 27 2023 10:58:56
%S 0,0,1,0,2,1,1,0,3,2,3,1,2,1,1,0,4,3,5,2,5,3,4,1,3,2,3,1,2,1,1,0,5,4,
%T 7,3,8,5,7,2,7,5,8,3,7,4,5,1,4,3,5,2,5,3,4,1,3,2,3,1,2,1,1,0,6,5,9,4,
%U 11,7,10,3,11,8,13,5,12,7,9,2,9,7,12,5,13,8,11,3,10,7,11,4,9,5,6,1,5,4,7,3,8
%N Stern's diatomic series type ([0,1], 1).
%C A variant of Stern's diatomic series A002487. See the link [Luschny] and the Maple function below for the classification by types which is based on a generalization of Dijkstra's fusc function.
%C a(n) is also the number of superduperbinary integer partitions of n.
%C It appears that a(n) is equal to the multiplicative inverse of A002487(n+2) mod A002487(n+1). - _Gary W. Adamson_, Dec 23 2023
%H Peter Luschny, <a href="/A174980/b174980.txt">row(n) for n = 0..12</a>
%H Edsger Dijkstra, <a href="http://www.cs.utexas.edu/users/EWD/ewd05xx/EWD578.PDF">EWD 578: More about the function 'fusc'</a>, Selected Writings on Computing, Springer, 1982, p. 232.
%H Peter Luschny, <a href="http://www.oeis.org/wiki/User:Peter_Luschny/SternsDiatomic">Rational Trees and Binary Partitions</a>.
%H Moritz A. Stern, <a href="http://www.digizeitschriften.de/resolveppn/GDZPPN002150301">Über eine zahlentheoretische Funktion</a>, J. Reine Angew. Math., 55 (1858), 193-220.
%F Recursion: a(2n + 1) = a(n) and a(2n) = a(n - 1) + a(n) + [n = 2^k] for n = 1, a(0) = 0. [n = 2^k] is 1 if n is a power of 2, 0 otherwise.
%e The sequence splits into rows of length 2^k:
%e 0,
%e 0, 1,
%e 0, 2, 1, 1,
%e 0, 3, 2, 3, 1, 2, 1, 1,
%e 0, 4, 3, 5, 2, 5, 3, 4, 1, 3, 2, 3, 1, 2, 1, 1,
%e ...
%e .
%e The first few partitions counted are:
%e [ 0], []
%e [ 1], []
%e [ 2], [[2]]
%e [ 3], []
%e [ 4], [[4], [2, 2]]
%e [ 5], [[4, 1]]
%e [ 6], [[4, 1, 1]]
%e [ 7], []
%e [ 8], [[8], [4, 4], [2, 2, 2, 2]]
%e [ 9], [[8, 1], [4, 4, 1]]
%e [10], [[8, 2], [8, 1, 1], [4, 4, 1, 1]]
%e [11], [[8, 2, 1]]
%e [12], [[8, 2, 2], [8, 2, 1, 1]]
%e [13], [[8, 2, 2, 1]]
%e [14], [[8, 2, 2, 1, 1]]
%e [15], []
%e [16], [[16], [8, 8], [4, 4, 4, 4], [2, 2, 2, 2, 2, 2, 2, 2]]
%e [17], [[16, 1], [8, 8, 1], [4, 4, 4, 4, 1]]
%e [18], [[16, 2], [8, 8, 2], [16, 1, 1], [8, 8, 1, 1], [4, 4, 4, 4, 1, 1]]
%e [19], [[16, 2, 1], [8, 8, 2, 1]]
%e [20], [[16, 4], [16, 2, 2], [8, 8, 2, 2], [16, 2, 1, 1], [8, 8, 2, 1, 1]]
%e [21], [[16, 4, 1], [16, 2, 2, 1], [8, 8, 2, 2, 1]]
%e [22], [[16, 4, 2], [16, 4, 1, 1], [16, 2, 2, 1, 1], [8, 8, 2, 2, 1, 1]]
%e [23], [[16, 4, 2, 1]]
%e [24], [[16, 4, 4], [16, 4, 2, 2], [16, 4, 2, 1, 1]]
%p SternDijkstra := proc(L, p, n) local k, i, len, M; len := nops(L); M := L; k := n; while k > 0 do M[1+(k mod len)] := add(M[i], i=1..len); k := iquo(k, len); od; op(p, M) end:
%p a := n -> SternDijkstra([0,1], 1, n);
%t a[0] = 0; a[n_?OddQ] := a[n] = a[(n-1)/2]; a[n_?EvenQ] := a[n] = a[n/2 - 1] + a[n/2] + Boole[ IntegerQ[ Log[2, n/2]]]; Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Jul 26 2013 *)
%o (SageMath)
%o def A174980(n):
%o M = [0, 1]
%o for b in n.bits():
%o M[b] = M[0] + M[1]
%o return M[0]
%o print([A174980(n) for n in (0..100)]) # _Peter Luschny_, Nov 28 2017
%o (Python) # Generating the partitions.
%o def SDBinaryPartition(n):
%o def Double(W, T):
%o B = []
%o for L in W:
%o A = [a*2 for a in L]
%o if T > 0: A += [1]*T
%o B.append(A)
%o return B
%o if n == 2: return [[2]]
%o if n < 4: return []
%o h = n // 2
%o H = SDBinaryPartition(h)
%o B = Double(H, n % 2)
%o if n % 2 == 0:
%o H = SDBinaryPartition(h - 1)
%o if H != []: B += Double(H, 2)
%o if (n & (n - 1)) == 0: B.append([2]*h)
%o return B
%o for n in range(25): print([n], SDBinaryPartition(n)) # _Peter Luschny_, Sep 02 2019
%Y Cf. A002487, A070879, A047679, A007306, A174981, A140429 (row sums), A086449.
%K easy,nonn,tabf,look
%O 0,5
%A _Peter Luschny_, Apr 03 2010