This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A227542 #37 May 04 2023 15:14:42 %S A227542 0,0,1,0,2,3,1,2,4,5,3,4,6,7,5,6,8,9,7,8,10,11,9,10,12,13,11,12,14,15, %T A227542 13,14,16,17,15,16,18,19,17,18,20,21,19,20,22,23,21,22,24,25,23,24,26, %U A227542 27,25,26,28,29,27,28,30,31,29,30,32,33,31,32,34,35,33,34,36,37,35,36,38,39,37,38,40,41,39,40,42,43,41,42,44,45,43,44,46 %N A227542 a(n) is the number of all terms preceding a(n-1) that have the same even-odd parity as a(n-1). %C A227542 If a(n-1) is even, a(n) is the count of all even members preceding a(n-1). If a(n-1) is odd, then a(n) is the count of all odd members preceding a(n-1). %H A227542 Andres M. Torres, <a href="/A227542/b227542.txt">Table of n, a(n) for n = 0..9999</a> %H A227542 <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,0,0,1,-1) %F A227542 G.f.: x^2 + x^4*(2+x-2*x^2+x^3) / ( (1+x)*(1+x^2)*(x-1)^2 ). - _R. J. Mathar_, Jul 22 2013 %F A227542 a(n) = (-3 - (-1)^n + (2+2*i)*(-i)^n + (2-i*2)*i^n + 2*n) / 4 for n>2, where i=sqrt(-1). - _Colin Barker_, Oct 16 2015 %e A227542 {0,0} : a(1)=0, because no values exist before a(0)=0. %e A227542 {0,0,1} : a(2)=1, because 1 even value exists before a(1)=0. %e A227542 {0,0,1,0} : a(3)=0, because no odd values exist before a(2)=1. %e A227542 {0,0,1,0,2} : a(4)=2, because 2 even values exist before a(3)=0. %e A227542 {0,0,1,0,2,3}: a(5)=3, because 3 even values exist before a(4)=2. %p A227542 A227542 := proc(n) %p A227542 option remember; %p A227542 local pari,a,i ; %p A227542 if n = 0 then %p A227542 0; %p A227542 else %p A227542 pari := type(procname(n-1),'even') ; %p A227542 a := 0 ; %p A227542 for i from 0 to n-2 do %p A227542 if type(procname(i),'even') = pari then %p A227542 a := a+1 ; %p A227542 end if; %p A227542 end do: %p A227542 a ; %p A227542 end if; %p A227542 end proc: # _R. J. Mathar_, Jul 22 2013 %t A227542 Join[{0,0,1},LinearRecurrence[{1,0,0,1,-1},{0,2,3,1,2},100]] (* _Harvey P. Dale_, Oct 01 2013 *) %o A227542 (Blitz3D) %o A227542 ;; [Blitz3D] Basic code %o A227542 ;; --a two index array to store counts of evens and odds %o A227542 Global EvenOdd[2] %o A227542 ;; store the sequence in an array %o A227542 Global a[10001] %o A227542 eo =0 ;; eo is a temporary variable %o A227542 a[1] = 0 ;; seq starts with "0" %o A227542 For z=1 To 10000 ;; create about 10000 values %o A227542 eo = isOdd(a[z]) %o A227542 a[z+1] = EvenOdd[eo] %o A227542 EvenOdd[eo] = EvenOdd[eo] +1 %o A227542 Next %o A227542 ;; returns 1 if v is ODD, else returns zero %o A227542 Function isOdd(v) %o A227542 Return v Mod 2 %o A227542 End Function %o A227542 Function isEven(v) %o A227542 Return (v Mod 2)=0 %o A227542 End Function %o A227542 (PARI) a(n) = if(n==1, 0, if(n==2, 1, (-3 - (-1)^n + (2+2*I)*(-I)^n + (2-I*2)*I^n + 2*n) / 4)) \\ _Colin Barker_, Oct 16 2015 %o A227542 (PARI) concat(vector(2), Vec((2*x^7-3*x^6+x^5+2*x^4-x^3+x^2)/(x^5-x^4-x+1) + O(x^100))) \\ _Colin Barker_, Oct 16 2015 %K A227542 nonn,easy %O A227542 0,5 %A A227542 _Andres M. Torres_, Jul 15 2013