The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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

%I #22 Jun 30 2022 02:06:56

%S 3,2,6,5,13,9,30,29,26,22,21,57,49,50,53,38,45,41,125,122,113,117,98,

%T 110,65,70,69,77,73,94,85,253,241,242,230,229,233,194,197,201,221,217,

%U 213,129,134,133,157,149,189,185,177,181,161,173,510,506,502,501

%N prime(n) Gray code decoding.

%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/GrayCode.html">Gray code</a>.

%F a(n) = A006068(A000040(n)). - _Joerg Arndt_, Nov 01 2020

%e f(x) = gray_code_to_natural(x) = A006068(x),

%e a(1) = f(2) = 3,

%e a(2) = f(3) = 2,

%e a(3) = f(5) = 6,

%e a(4) = f(7) = 5,

%e a(5) = f(11) = 13.

%t Array[BitXor @@ Table[Floor[#/2^m], {m, 0, Floor@ Log2[#]}] &@ Prime[#] &, 58] (* _Michael De Vlieger_, Nov 05 2020 *)

%o (Ruby) require 'prime'

%o values = Prime.first(50).map { |x| x ^= x >> 16; x ^= x >> 8; x ^= x >> 4; x ^= x >> 2; x ^= x >> 1; x }

%o p values

%o (Python)

%o from sympy import prime

%o def A338524(n):

%o k = prime(n)

%o m = k>>1

%o while m > 0:

%o k ^= m

%o m >>= 1

%o return k # _Chai Wah Wu_, Jun 29 2022

%Y Cf. A000040, A006068, A143292 (Gray code of prime(n)).

%K nonn

%O 1,1

%A _Simon Strandgaard_, Nov 01 2020

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 June 4 07:50 EDT 2024. Contains 373092 sequences. (Running on oeis4.)