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.

A342122 a(n) is the remainder when the binary reverse of n is divided by n.

This page as a plain text file.
%I A342122 #20 Mar 01 2023 08:44:59
%S A342122 0,1,0,1,0,3,0,1,0,5,2,3,11,7,0,1,0,9,6,5,0,13,6,3,19,11,0,7,23,15,0,
%T A342122 1,0,17,14,9,4,25,18,5,37,21,10,13,0,29,14,3,35,19,0,11,43,27,4,7,39,
%U A342122 23,55,15,47,31,0,1,0,33,30,17,12,49,42,9,0,41,30
%N A342122 a(n) is the remainder when the binary reverse of n is divided by n.
%C A342122 The binary reverse of a number is given by A030101.
%C A342122 This sequence is the analog of A103168 for the binary base.
%H A342122 Rémy Sigrist, <a href="/A342122/b342122.txt">Table of n, a(n) for n = 1..8192</a>
%H A342122 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A342122 a(n) = A030101(n) mod n.
%F A342122 a(n) < n.
%F A342122 a(n) = 0 iff n is a binary palindrome (A006995).
%e A342122 For n = 43,
%e A342122 - the binary reverse of 43 ("101011" in binary) is 53 ("110101" in binary),
%e A342122 - so a(43) = 53 mod 43 = 10.
%t A342122 Table[Mod[FromDigits[Reverse[IntegerDigits[n,2]],2],n],{n,80}] (* _Harvey P. Dale_, Mar 01 2023 *)
%o A342122 (PARI) a(n, base=2) = { my (r=fromdigits(Vecrev(digits(n, base)), base)); r%n }
%o A342122 (Python)
%o A342122 def A342122(n): return int(bin(n)[:1:-1],2) % n if n > 0 else 0 # _Chai Wah Wu_, Mar 01 2021
%Y A342122 Cf. A006995, A030101, A103168, A342121, A342123.
%K A342122 nonn,base,look,easy
%O A342122 1,6
%A A342122 _Rémy Sigrist_, Feb 28 2021