OFFSET
1,1
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
A. Karttunen and J. Moyer, C-program for computing the initial terms of this sequence
MAPLE
q:= proc(n) local i, l, r; l, r:= convert(n, base, 2), 0;
for i to nops(l) while l[i]=1 do r:=r+1 od; is(r, odd)
end:
select(q, [ithprime(i)$i=1..150])[]; # Alois P. Heinz, Dec 15 2019
MATHEMATICA
Select[Prime[Range[100]], MatchQ[IntegerDigits[#, 2], {b:(1)..}|{___, 0, b:(1)..} /; OddQ[Length[{b}]]]&] (* Jean-François Alcover, Jan 03 2022 *)
PROG
(PARI) is(n)=valuation(n+1, 2)%2 && isprime(n) \\ Charles R Greathouse IV, Oct 09 2013
(Python)
from sympy import isprime
def ok(n): b = bin(n); return (len(b)-len(b.rstrip("1")))%2 and isprime(n)
print([k for k in range(1, 401) if ok(k)]) # Michael S. Branicky, Jan 03 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Antti Karttunen, Jun 04 2004
STATUS
approved