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.

A342410 The binary expansion of a(n) corresponds to that of n where all the 1's have been replaced by 0's except in the last run of 1's.

This page as a plain text file.
%I A342410 #80 Apr 30 2021 06:15:52
%S A342410 0,1,2,3,4,1,6,7,8,1,2,3,12,1,14,15,16,1,2,3,4,1,6,7,24,1,2,3,28,1,30,
%T A342410 31,32,1,2,3,4,1,6,7,8,1,2,3,12,1,14,15,48,1,2,3,4,1,6,7,56,1,2,3,60,
%U A342410 1,62,63,64,1,2,3,4,1,6,7,8,1,2,3,12,1,14,15
%N A342410 The binary expansion of a(n) corresponds to that of n where all the 1's have been replaced by 0's except in the last run of 1's.
%C A342410 In other words, this sequence gives the last run of 1's in the binary expansion of a number.
%H A342410 Rémy Sigrist, <a href="/A342410/b342410.txt">Table of n, a(n) for n = 0..8192</a>
%H A342410 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A342410 a(2*n) = 2*a(n).
%F A342410 a(a(n)) = a(n).
%F A342410 a(n) <= n with equality iff n belongs to A023758.
%e A342410 The first terms, alongside their binary expansion, are:
%e A342410   n   a(n)  bin(n)  bin(a(n))
%e A342410   --  ----  ------  ---------
%e A342410    0     0       0          0
%e A342410    1     1       1          1
%e A342410    2     2      10         10
%e A342410    3     3      11         11
%e A342410    4     4     100        100
%e A342410    5     1     101          1
%e A342410    6     6     110        110
%e A342410    7     7     111        111
%e A342410    8     8    1000       1000
%e A342410    9     1    1001          1
%e A342410   10     2    1010         10
%e A342410   11     3    1011         11
%e A342410   12    12    1100       1100
%e A342410   13     1    1101          1
%e A342410   14    14    1110       1110
%e A342410   15    15    1111       1111
%t A342410 Array[FromDigits[If[Length[s=Split@IntegerDigits[#,2]]>1,Flatten[s[[-2;;]]],First@s],2]&,100,0] (* _Giorgos Kalogeropoulos_, Apr 27 2021 *)
%o A342410 (PARI) a(n) = { if (n, my (z=valuation(n, 2), o=valuation(n/2^z+1, 2)); (2^o-1)*2^z, 0) }
%o A342410 (Python)
%o A342410 def A342410(n):
%o A342410     if n == 0 : return 0
%o A342410     for i, d in enumerate(bin(n)[2:].split('0')[::-1]):
%o A342410         if d != '': return int(d+'0'*i,2) # _Chai Wah Wu_, Apr 29 2021
%Y A342410 Cf. A023758, A089309, A135481, A342126.
%K A342410 nonn,base,easy
%O A342410 0,3
%A A342410 _Rémy Sigrist_, Apr 25 2021