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.

A342121 a(n) is the remainder when the larger of n and its binary reverse is divided by the smaller.

This page as a plain text file.
%I A342121 #22 Mar 18 2023 15:56:19
%S A342121 0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,6,0,0,9,6,0,6,4,0,0,6,0,0,0,0,0,
%T A342121 14,0,4,13,18,0,4,0,10,5,0,17,14,0,14,12,0,8,10,0,4,0,18,12,4,0,14,0,
%U A342121 0,0,0,0,30,0,12,21,42,0,0,33,30,1,12,21,42,0
%N A342121 a(n) is the remainder when the larger of n and its binary reverse is divided by the smaller.
%C A342121 The binary reverse of a number is given by A030101.
%C A342121 This sequence is the analog of A061467 for the binary base.
%H A342121 Rémy Sigrist, <a href="/A342121/b342121.txt">Table of n, a(n) for n = 1..8192</a>
%H A342121 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A342121 a(n) = max(n, A030101(n)) mod min(n, A030101(n)).
%F A342121 a(n) = min(A342122(n), A342123(n)).
%F A342121 a(n) < n.
%F A342121 a(n) = 0 iff n belongs to A057890.
%e A342121 For n = 43,
%e A342121 - the binary reverse of 43 ("101011" in binary) is 53 ("110101" in binary),
%e A342121 - so a(43) = 53 mod 43 = 10.
%t A342121 rbr[n_]:=Module[{r=IntegerReverse[n,2]},If[r>n,Mod[r,n],Mod[n,r]]]; Array[rbr,100] (* _Harvey P. Dale_, Mar 18 2023 *)
%o A342121 (PARI) a(n, base=2) = { my (r=fromdigits(Vecrev(digits(n, base)), base)); max(n, r) % min(n, r) }
%o A342121 (Python)
%o A342121 def A342121(n):
%o A342121     a, b = sorted([n,int(bin(n)[:1:-1],2)])
%o A342121     return b % a if n > 0 else 0 # _Chai Wah Wu_, Mar 01 2021
%Y A342121 Cf. A030101, A057890, A061467, A342122, A342123..
%K A342121 nonn,base,look,easy
%O A342121 1,11
%A A342121 _Rémy Sigrist_, Feb 28 2021