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.

A075897 1 if binary weight of n is 1 or 2, otherwise 0.

This page as a plain text file.
%I A075897 #31 Jan 11 2022 08:24:00
%S A075897 0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,
%T A075897 1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,
%U A075897 1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
%N A075897 1 if binary weight of n is 1 or 2, otherwise 0.
%H A075897 <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>
%F A075897 a(n) = 1 if n is in A048645, 0 otherwise.
%F A075897 For n>0: a(n) = 0^floor(A000120(n)/3). - _Reinhard Zumkeller_, Apr 07 2003
%t A075897 Table[If[MemberQ[{1,2},Total[IntegerDigits[n,2]]],1,0],{n,0,120}] (* _Harvey P. Dale_, Jul 26 2017 *)
%o A075897 (PARI) a(n)=(hammingweight(n)+1)\2 == 1 \\ _Charles R Greathouse IV_, Jan 10 2022
%o A075897 (PARI) a(n)=(hammingweight(n)) <= 2 && n > 0 \\ _David A. Corneth_, Jan 11 2022
%o A075897 (Python)
%o A075897 def a(n): return int(bin(n).count('1') in [1, 2])
%o A075897 print([a(n) for n in range(105)]) # _Michael S. Branicky_, Jan 11 2022
%Y A075897 Cf. A000120, A048645.
%K A075897 nonn,easy
%O A075897 0,1
%A A075897 _Benoit Cloitre_, Mar 29 2003