OFFSET
1,1
COMMENTS
From Emeric Deutsch, Jan 28 2018: (Start)
Also the indices of the compositions that have a prime number of parts. For the definition of the index of a composition see A298644.
For example, 27 is in the sequence since its binary form is 11011 and the composition [2,1,2] has 3 parts.
On the other hand, 58 is not in the sequence since its binary form is 111010 and the composition [3,1,1,1] has 4 parts.
The command c(n) from the Maple program yields the composition having index n. (End)
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..10001
Wikipedia, Gray code.
EXAMPLE
27 is in the sequence because the binary reflected Gray code representation of 27 is 10110 which has 3 1's, and 3 is prime.
MAPLE
Runs := proc (L) local j, r, i, k: j := 1: r[j] := L[1]:
for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1:
r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc:
RunLengths := proc (L) map(nops, Runs(L)) end proc:
c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc:
A := {}: for n to 175 do if isprime(nops(c(n))) = true then A := `union`(A, {n}) else end if end do: A;
# most of the program is due to W. Edwin Clark. # Emeric Deutsch, Jan 28 2018
MATHEMATICA
Select[Range[100], PrimeQ[DigitCount[BitXor[#, Floor[#/2]], 2, 1]] &] (* Amiram Eldar, May 01 2021 *)
PROG
(PARI) is(n)=isprime(hammingweight(bitxor(n, n>>1))) \\ Charles R Greathouse IV, Jan 12 2017
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Indranil Ghosh, Jan 12 2017
STATUS
approved