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.

A161154 Positive integers n such that both {the number of (non-leading) 0's in the binary representation of n} is coprime to n and {the number of 1's in the binary representation of n} is coprime to n.

This page as a plain text file.
%I A161154 #21 Jun 28 2025 10:56:09
%S A161154 1,2,5,8,9,11,13,14,17,19,23,25,27,29,32,33,35,37,38,39,41,43,44,45,
%T A161154 47,49,50,51,52,53,56,57,59,61,62,67,71,73,77,79,83,85,87,89,91,93,95,
%U A161154 97,101,103,107,109,113,117,119,121,125,128,131,133,134,135,137,139,141
%N A161154 Positive integers n such that both {the number of (non-leading) 0's in the binary representation of n} is coprime to n and {the number of 1's in the binary representation of n} is coprime to n.
%C A161154 1 is the only integer of the form 2^k - 1 (k>=0) included in this sequence, because such integers contain no binary 0's, and 0 is considered here to be coprime only to 1.
%H A161154 Indranil Ghosh, <a href="/A161154/b161154.txt">Table of n, a(n) for n = 1..1000</a>
%t A161154 bcpQ[n_]:=Module[{ones=DigitCount[n,2,1],zeros=DigitCount[n,2,0]}, And@@ CoprimeQ[ {ones,zeros},n]]; Select[Range[150],bcpQ] (* _Harvey P. Dale_, Feb 19 2012 *)
%o A161154 (PARI) b0(n) = if(n<1, 0, b0(n\2) + 1 - n%2);
%o A161154 b1(n) = if(n<1, 0, b1(n\2) + n%2);
%o A161154 for (n=1, 141, if(gcd(b0(n),n)==1 && gcd(b1(n),n)==1, print1(n", "))) \\ _Indranil Ghosh_, Mar 08 2017
%o A161154 (Python)
%o A161154 from math import gcd
%o A161154 i=j=1
%o A161154 while j<=100:
%o A161154     if gcd(bin(i)[2:].count("0"),i)==1==gcd(bin(i)[2:].count("1"),i):
%o A161154         print(j, i)
%o A161154         j+=1
%o A161154     i+=1 # _Indranil Ghosh_, Mar 08 2017
%Y A161154 Cf. A094387, A161152, A161153, A161155, A161156.
%K A161154 base,nonn
%O A161154 1,2
%A A161154 _Leroy Quet_, Jun 03 2009
%E A161154 Extended by _Ray Chandler_, Jun 11 2009