cp's OEIS Frontend

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.

A164126 First differences of A006995.

This page as a plain text file.
%I A164126 #34 Jun 12 2024 01:16:10
%S A164126 1,2,2,2,2,6,2,4,6,4,2,12,6,12,2,8,12,8,6,8,12,8,2,24,12,24,6,24,12,
%T A164126 24,2,16,24,16,12,16,24,16,6,16,24,16,12,16,24,16,2,48,24,48,12,48,24,
%U A164126 48,6,48,24,48,12,48,24,48,2,32,48,32,24,32,48,32,12,32,48,32,24,32,48,32,6
%N A164126 First differences of A006995.
%C A164126 Contribution from _Hieronymus Fischer_, Feb 18 2012: (Start)
%C A164126 From the formula section it follows that a(2^m - 1 + 2^(m-1) - k) = a(2^m - 1 + k) for 0 <= k <= 2^(m-1), as well as a(2^m - 1 + 2^(m-1) - k) = 2 for k=0, 2^(m-1) and a(2^m - 1 + 2^(m-1) - k) = 6 for k=2^(m-2), hence, starting from positions n=2^m-1, the following 2^(m-1) terms form symmetric tuples limited on the left and on the right by a '2' and always having a '6' as the center element.
%C A164126 Example: for n = 15 = 2^4 - 1, we have the (2^3+1)-tuple (2,8,12,8,6,8,12,8,2).
%C A164126 Further on, since a(2^m - 1 + 2^(m-1) + k) = a(2^(m+1) - 1 - k) for 0 <= k <= 2^(m-1) an analogous statement holds true for starting positions n = 2^m + 2^(m-1) - 1.
%C A164126 Example: for n = 23 = 2^4 + 2^3 - 1, we find the (2^3+1)-tuple (2,24,12,24,6,24,12,24,2).
%C A164126 If we group the sequence terms according to the value of m=floor(log_2(n)), writing those terms together in separate lines and opening each new line for n >= 2^m + 2^(m-1), then a kind of a 'logarithmic shaped' cone end will be formed, where both the symmetry and the calculation rules become obvious. The first 63 terms are depicted below:
%C A164126                           1
%C A164126                           2
%C A164126                           2
%C A164126                         2  2
%C A164126                         6  2
%C A164126                       4 6  4  2
%C A164126                      12 6 12  2
%C A164126                 8 12  8 6  8 12  8 2
%C A164126                24 12 24 6 24 12 24 2
%C A164126    16 24 16 12 16 24 16 6 16 24 16 12 16 24 16 2
%C A164126    48 24 48 12 48 24 48 6 48 24 48 12 48 24 48 2
%C A164126 .
%C A164126 (End)
%C A164126 Decremented by 1, also the sequence of run lengths of 0's in A178225. - _Hieronymus Fischer_, Feb 19 2012
%H A164126 Vincenzo Librandi, <a href="/A164126/b164126.txt">Table of n, a(n) for n = 1..1000</a>
%F A164126 a(n) = A006995(n+1) - A006995(n).
%F A164126 Contribution from _Hieronymus Fischer_, Feb 17 2012: (Start)
%F A164126 a(4*2^m - 1) = a(6*2^m - 1) = 2;
%F A164126 a(5*2^m - 1) = a(7*2^m - 1) = 6 (for m > 0);
%F A164126 Let m = floor(log_2(n)), then
%F A164126   Case 1: a(n) = 2, if n+1 = 2^(m+1) or n+1 = 3*2^(m-1);
%F A164126   Case 2: a(n) = 2^(m-1), if n = 0(mod 2) and n < 3*2^(m-1);
%F A164126   Case 3: a(n) = 3*2^(m-1), if n = 0(mod 2) and n >= 3*2^(m-1);
%F A164126   Case 4: a(n) = 3*2^(m-1)/gcd(n+1-2^m, 2^m), otherwise.
%F A164126 Cases 2-4 above can be combined as
%F A164126   Case 2': a(n) = (2 - (-1)^(n-(n-1)*floor(2*n/(3*2^m))))*2^(m-1)/gcd(n+1-2^m, 2^m).
%F A164126 Recursion formula:
%F A164126 Let m = floor(log_2(n)); then
%F A164126   Case 1: a(n) = 2*a(n-2^(m-1)), if 2^m <= n < 2^m + 2^(m-2) - 1;
%F A164126   Case 2: a(n) = 6, if n = 2^m + 2^(m-2) - 1;
%F A164126   Case 3: a(n) = a(n-2^(m-2)), if 2^m + 2^(m-2) <= n < 2^m + 2^(m-1) - 1;
%F A164126   Case 4: a(n) = 2, if n = 2^m + 2^(m-1) - 1;
%F A164126   Case 5: a(n) = (2 + (-1)^n)*a(n-2^(m-1)), otherwise (which means 2^m + 2^(m-1) <= n < 2^(m+1)).
%F A164126 (End)
%e A164126 a(1) = A006995(2) - A006995(1) = 1 - 0 = 1.
%t A164126 f[n_]:=FromDigits[RealDigits[n,2][[1]]]==FromDigits[Reverse[RealDigits[n, 2][[1]]]]; a=1;lst={};Do[If[f[n],AppendTo[lst,n-a];a=n],{n,1,8!,1}]; lst
%o A164126 (Python)
%o A164126 def A164126(n):
%o A164126     if n == 1: return 1
%o A164126     m = (a:=1<<(l:=n.bit_length()-2))|(n&a-1)
%o A164126     k = (m<<l+1)+int(bin(m)[-1:1:-1]or'0',2) if a&n else (m<<l)+int(bin(m)[-2:1:-1]or'0',2)
%o A164126     m = (a:=1<<(l:=(n+1).bit_length()-2))|(n+1&a-1)
%o A164126     return ((m<<l+1)+int(bin(m)[-1:1:-1]or'0',2) if a&n+1 else (m<<l)+int(bin(m)[-2:1:-1]or'0',2))-k # _Chai Wah Wu_, Jun 11 2024
%Y A164126 Cf. A006995, A164124, A029971, A016041, A164125.
%Y A164126 See A178225.
%K A164126 nonn,base,easy
%O A164126 1,2
%A A164126 _Vladimir Joseph Stephan Orlovsky_, Aug 10 2009
%E A164126 a(1) changed to 1 and keyword:base added by _R. J. Mathar_, Aug 26 2009