login
Decimal value of the reverse binary expansion of the prime numbers.
8

%I #28 Oct 19 2022 06:43:35

%S 1,3,5,7,13,11,17,25,29,23,31,41,37,53,61,43,55,47,97,113,73,121,101,

%T 77,67,83,115,107,91,71,127,193,145,209,169,233,185,197,229,181,205,

%U 173,253,131,163,227,203,251,199,167,151,247,143,223,257,449,353,481,337

%N Decimal value of the reverse binary expansion of the prime numbers.

%C 15 of the first 16 terms happen to be prime. As terms increase, the preponderance of primes apparently decreases.

%H Rémy Sigrist, <a href="/A098957/b098957.txt">Table of n, a(n) for n = 1..6542</a>

%F a(n) = decimal(reverse(binary(prime(n)))) where prime(n) is the n-th prime.

%F a(n) = A030101(A000040(n)). - _Rémy Sigrist_, Oct 19 2022

%e a(14) = 53 because the 14th prime is 43, or 101011 binary; reverse of 101011 is 110101, or 53 decimal.

%p a:= proc(n) local m, r; m, r:= ithprime(n), 0;

%p while m>0 do r:= r*2+irem(m, 2, 'm') od; r

%p end:

%p seq(a(n), n=1..60); # _Alois P. Heinz_, Mar 08 2018

%t Table[FromDigits[Reverse[IntegerDigits[Prime[n], 2]], 2], {n, 100}] (* _Alonso del Arte_, Mar 05 2018 *)

%o (PARI) a(n)=my(v=binary(prime(n)),s);forstep(i=#v,1,-1,s+=s+v[i]);s \\ _Charles R Greathouse IV_, Aug 17 2011

%o (Python)

%o from sympy import prime

%o def A098957(n): return int(bin(prime(n))[:1:-1],2) # _Chai Wah Wu_, Feb 17 2022

%Y Cf. A000040, A030101.

%K base,nonn

%O 1,2

%A _Gil Broussard_, Oct 21 2004