%I #25 May 09 2021 12:44:06
%S 1,1,1,3,2,2,5,4,3,9,6,4,14,9,8,22,15,11,37,24,21,58,40,30,95,67,53,
%T 157,114,85,264,187,147,428,315,244,732,527,410,1207,892,681,2034,
%U 1490,1155,3416,2508,1927,5731,4215,3259,9597,7091,5454,16175,11914,9194,27134,20033,15425,45649,33672,25967,76714
%N Number of compositions of n where each part after the first is either twice or half the prior part.
%C All quotients of adjacent parts are either 1/2 or 2.
%H Alois P. Heinz, <a href="/A342331/b342331.txt">Table of n, a(n) for n = 0..5000</a> (first 1001 terms from Andrew Howroyd)
%e The a(1) = 1 through a(12) = 14 compositions (A = 10, B = 11, C = 12):
%e 1 2 3 4 5 6 7 8 9 A B C
%e 12 121 212 24 124 242 36 424 21242 48
%e 21 42 421 21212 63 12124 24212 84
%e 1212 12121 1242 12421 2121212 363
%e 2121 2124 42121 2424
%e 2421 1212121 4242
%e 4212 121242
%e 121212 124212
%e 212121 212124
%e 212421
%e 242121
%e 421212
%e 12121212
%e 21212121
%p b:= proc(n, i) option remember; `if`(n=0, 1, add(b(n-j, j), j=
%p `if`(i=0, 1..n, select(t-> t::integer and t<=n, {2*i, i/2}))))
%p end:
%p a:= n-> b(n, 0):
%p seq(a(n), n=0..80); # _Alois P. Heinz_, Mar 14 2021
%t Table[Length[Select[Join@@Permutations/@IntegerPartitions[n],And@@Table[#[[i]]==2*#[[i-1]]||#[[i-1]]==2*#[[i]],{i,2,Length[#]}]&]],{n,0,15}]
%t (* Second program: *)
%t b[n_, i_] := b[n, i] = If[n == 0, 1, Sum[b[n - j, j], {j, If[i == 0, Range[n], Select[{2i, i/2}, IntegerQ[#] && # <= n &]]}]];
%t a[n_] := b[n, 0];
%t a /@ Range[0, 80] (* _Jean-François Alcover_, May 09 2021, after _Alois P. Heinz_ *)
%o (PARI) seq(n)={my(M=matid(n)); for(k=1, n, for(i=1, k-1, M[i, k] = if(i%2==0,M[i/2,k-i]) + if(i*3<=k, M[i*2,k-i]))); concat([1], sum(q=1, n, M[q, ]))} \\ _Andrew Howroyd_, Mar 13 2021
%Y The unordered version (partitions) is A154402.
%Y The version allowing equality is A342340.
%Y A000929 counts partitions with all adjacent parts x >= 2y.
%Y A002843 counts compositions with all adjacent parts x <= 2y.
%Y A224957 counts compositions with all x <= 2y and y <= 2x (strict: A342342).
%Y A274199 counts compositions with all adjacent parts x < 2y.
%Y A342094 counts partitions with all adjacent x <= 2y (strict: A342095).
%Y A342096 counts partitions with no adjacent x >= 2y (strict: A342097).
%Y A342098 counts partitions with all adjacent parts x > 2y.
%Y A342330 counts compositions with all x < 2y and y < 2x (strict: A342341).
%Y A342332 counts compositions with all adjacent parts x > 2y or y > 2x.
%Y A342333 counts compositions with adjacent parts x >= 2y or y >= 2x.
%Y A342335 counts compositions with all adjacent parts x >= 2y or y = 2x.
%Y A342337 counts partitions with all adjacent parts x = y or x = 2y.
%Y A342338 counts compositions with all adjacent parts x < 2y and y <= 2x.
%Y Cf. A003114, A003242, A167606, A342083, A342084, A342087, A342191, A342334, A342336, A342339.
%K nonn
%O 0,4
%A _Gus Wiseman_, Mar 09 2021
%E More terms from _Joerg Arndt_, Mar 12 2021