login
A280998
Numbers with a prime number of 1's in their binary reflected Gray code representation.
5
2, 4, 5, 6, 8, 9, 11, 12, 13, 14, 16, 17, 19, 21, 23, 24, 25, 27, 28, 29, 30, 32, 33, 35, 37, 39, 41, 43, 45, 47, 48, 49, 51, 53, 55, 56, 57, 59, 60, 61, 62, 64, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 96, 97, 99, 101, 103
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
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