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!)
A338524 prime(n) Gray code decoding. 1
3, 2, 6, 5, 13, 9, 30, 29, 26, 22, 21, 57, 49, 50, 53, 38, 45, 41, 125, 122, 113, 117, 98, 110, 65, 70, 69, 77, 73, 94, 85, 253, 241, 242, 230, 229, 233, 194, 197, 201, 221, 217, 213, 129, 134, 133, 157, 149, 189, 185, 177, 181, 161, 173, 510, 506, 502, 501 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
Eric Weisstein's World of Mathematics, Gray code.
FORMULA
a(n) = A006068(A000040(n)). - Joerg Arndt, Nov 01 2020
EXAMPLE
f(x) = gray_code_to_natural(x) = A006068(x),
a(1) = f(2) = 3,
a(2) = f(3) = 2,
a(3) = f(5) = 6,
a(4) = f(7) = 5,
a(5) = f(11) = 13.
MATHEMATICA
Array[BitXor @@ Table[Floor[#/2^m], {m, 0, Floor@ Log2[#]}] &@ Prime[#] &, 58] (* Michael De Vlieger, Nov 05 2020 *)
PROG
(Ruby) require 'prime'
values = Prime.first(50).map { |x| x ^= x >> 16; x ^= x >> 8; x ^= x >> 4; x ^= x >> 2; x ^= x >> 1; x }
p values
(Python)
from sympy import prime
def A338524(n):
k = prime(n)
m = k>>1
while m > 0:
k ^= m
m >>= 1
return k # Chai Wah Wu, Jun 29 2022
CROSSREFS
Cf. A000040, A006068, A143292 (Gray code of prime(n)).
Sequence in context: A125675 A301501 A072787 * A371906 A293549 A370377
KEYWORD
nonn
AUTHOR
Simon Strandgaard, Nov 01 2020
STATUS
approved

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 May 11 03:17 EDT 2024. Contains 372388 sequences. (Running on oeis4.)