%I #53 Sep 08 2019 12:03:43
%S 1,1,2,2,2,3,1,3,2,2,5,1,4,4,2,2,7,1,5,2,2,9,1,6,6,2,2,11,1,7,2,2,13,
%T 1,8,8,2,2,15,1,9,2,2,17,1,10,10,2,2,19,1,11,2,2,21,1,12,12,2,2,23,1,
%U 13,2,2,25,1,14,14,2,2,27,1,15,2,2
%N a(1)=1; a(n) = number of occurrences of a(n-1) if a(n-1) is odd; a(n) = number of occurrences of a(n-2) if a(n-1) is even.
%H Colin Barker, <a href="/A306399/b306399.txt">Table of n, a(n) for n = 1..1000</a>
%H <a href="/index/Rec#order_22">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,-1).
%F From _Colin Barker_, Aug 24 2019: (Start)
%F G.f.: x*(1 + x + 2*x^2 + 2*x^3 + 2*x^4 + 3*x^5 + x^6 + 3*x^7 + 2*x^8 + 2*x^9 + 5*x^10 - x^11 + 2*x^12 - 2*x^14 - 2*x^15 + x^16 - x^17 - x^18 - 2*x^19 - 2*x^20 - x^21 - x^23) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10)^2).
%F a(n) = 2*a(n-11) - a(n-22) for n>24.
%F (End)
%e Since a(6) is odd, a(7) = number of occurrences of a(6). Number of occurrences of a(6)=3 up to that point is 1.
%e a(14) is even, so a(15) = number of occurrences of a(13). Number of occurrences of a(13)=4 up to that point is 2.
%t CoefficientList[Series[(1 + x + 2*x^2 + 2*x^3 + 2*x^4 + 3*x^5 + x^6 + 3*x^7 + 2*x^8 + 2*x^9 + 5*x^10 - x^11 + 2*x^12 - 2*x^14 - 2*x^15 + x^16 - x^17 - x^18 - 2*x^19 - 2*x^20 - x^21 - x^23)/((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10)^2), {x, 0, 100}], x] (* _Wesley Ivan Hurt_, Aug 24 2019 *)
%o (VBA/Excel)
%o Sub 306399()
%o Cells(1,1)=1
%o For n = 2 To 200
%o k = 2 - (Cells(n - 1, 1) Mod 2)
%o m = Cells(n - k, 1)
%o S = 0
%o For j = 1 To n - 1
%o If Cells(j, 1) = m Then
%o S = S + 1
%o End If
%o Next j
%o Cells(n, 1) = S
%o Next n
%o End Sub
%o (Python)
%o n, aa = 1, [1]
%o print(n,1)
%o while n <= 75:
%o sa = aa[len(aa)-2+aa[len(aa)-1]%2]
%o i, a = 0, 0
%o while i < len(aa):
%o if sa == aa[i]:
%o a = a+1
%o i = i+1
%o print(n,a)
%o n, aa = n+1, aa+[a] # _A.H.M. Smeets_, Aug 23 2019
%o (PARI) nbo(v, i) = #select(x->(x == v[i]), v);
%o lista(nn) = {v = vector(nn); v[1] = 1; for (k=2, nn, if (v[k-1] % 2, v[k] = nbo(v, k-1), v[k] = nbo(v, k-2));); v;} \\ _Michel Marcus_, Aug 24 2019
%o (PARI) Vec(x*(1 + x + 2*x^2 + 2*x^3 + 2*x^4 + 3*x^5 + x^6 + 3*x^7 + 2*x^8 + 2*x^9 + 5*x^10 - x^11 + 2*x^12 - 2*x^14 - 2*x^15 + x^16 - x^17 - x^18 - 2*x^19 - 2*x^20 - x^21 - x^23) / ((1 - x)^2*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10)^2) + O(x^80)) \\ _Colin Barker_, Aug 25 2019
%o (PARI) A306399_upto(N,c=Map([0;1]~),L,P)=vector(N,i,[P,L]=[L,mapget(c,if(bitand(L,1),L,P))];mapput(~c,L,iferr(mapget(c,L)+1,E,1));L) \\ _M. F. Hasler_, Sep 02 2019
%K nonn,easy
%O 1,3
%A _Ali Sada_, Aug 22 2019
|