login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A052294 Pernicious numbers: numbers with a prime number of 1's in their binary expansion. 19

%I #55 Dec 27 2023 23:57:47

%S 3,5,6,7,9,10,11,12,13,14,17,18,19,20,21,22,24,25,26,28,31,33,34,35,

%T 36,37,38,40,41,42,44,47,48,49,50,52,55,56,59,61,62,65,66,67,68,69,70,

%U 72,73,74,76,79,80,81,82,84,87,88,91,93,94,96,97,98,100

%N Pernicious numbers: numbers with a prime number of 1's in their binary expansion.

%C No power of 2 is pernicious, but 2^n+1 always is.

%C If a prime p is of the form 2^k -1, then p is included in this sequence. - _Leroy Quet_, Sep 20 2008

%C There are A121497(n) n-bit members of this sequence. - _Charles R Greathouse IV_, Mar 22 2013

%C A list of programming codes for pernicious numbers can be found in the Rosetta Code link. - _Martin Ettl_, May 27 2014

%H Iain Fox, <a href="/A052294/b052294.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from T. D. Noe, terms 1001..4000 from Daniel Arribas)

%H Rosetta Code, <a href="http://rosettacode.org/wiki/Pernicious_numbers">Pernicious numbers</a>

%e 26 is in the sequence because the binary expansion of 26 is 11010 and 11010 has three 1's and 3 is prime, so the number of 1's in the binary expansion of 26 is prime. - _Omar E. Pol_, Apr 04 2016

%p filter:= n -> isprime(convert(convert(n,base,2),`+`)):

%p select(filter, [$1..1000]); # _Robert Israel_, Oct 19 2014

%t Select[Range[6! ],PrimeQ[DigitCount[ #,2][[1]]]&] (* _Vladimir Joseph Stephan Orlovsky_, Feb 16 2010 *)

%o (Haskell)

%o a052294 n = a052294_list !! (n-1)

%o a052294_list = filter ((== 1) . a010051 . a000120) [1..]

%o -- _Reinhard Zumkeller_, Nov 16 2012

%o (PARI) is(n)=isprime(hammingweight(n)) \\ _Charles R Greathouse IV_, Mar 22 2013

%o (Python)

%o from sympy import isprime

%o def ok(n): return isprime(bin(n).count("1"))

%o print([k for k in range(101) if ok(k)]) # _Michael S. Branicky_, Jun 16 2022

%o (Python)

%o from sympy import isprime

%o def ok(n): return isprime(n.bit_count())

%o print([k for k in range(101) if ok(k)]) # _Michael S. Branicky_, Dec 27 2023

%Y Cf. A000069, A001969, A010051, A000120, A081092 (primes).

%Y Cf. A262481 (subsequence).

%K easy,base,nice,nonn

%O 1,1

%A Jeremy Gow (jeremygo(AT)dai.ed.ac.uk), Feb 08 2000

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 05:39 EDT 2024. Contains 371235 sequences. (Running on oeis4.)