cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A356434 Prime nearest to 2^n. In case of a tie, choose the larger.

This page as a plain text file.
%I A356434 #17 Feb 19 2023 15:10:48
%S A356434 2,2,5,7,17,31,67,127,257,509,1021,2053,4099,8191,16381,32771,65537,
%T A356434 131071,262147,524287,1048573,2097143,4194301,8388617,16777213,
%U A356434 33554467,67108859,134217757,268435459,536870909,1073741827,2147483647,4294967291,8589934583
%N A356434 Prime nearest to 2^n. In case of a tie, choose the larger.
%H A356434 Harvey P. Dale, <a href="/A356434/b356434.txt">Table of n, a(n) for n = 0..1000</a>
%F A356434 a(0) = 2; for n >= 1, if A014210(n) + A014234(n) > 2^(n+1) then a(n) = A014234(n), otherwise a(n) = A014210(n).
%t A356434 Join[{2,2},Table[Max[Nearest[{NextPrime[2^n,-1],NextPrime[2^n]},2^n]],{n,2,40}]] (* _Harvey P. Dale_, Feb 19 2023 *)
%o A356434 (Python)
%o A356434 from sympy import prevprime, nextprime
%o A356434 def A356434(n): return (r if (m:=nextprime(k:=1<<n)) > (k<<1)-(r:=prevprime(k)) else m) if n>1 else 2 # _Chai Wah Wu_, Aug 08 2022
%Y A356434 A117387 differs by preferring the smaller prime in the case of a tie, which occurs when n is in A226178.
%Y A356434 Cf. A014210, A014234, A340707.
%K A356434 nonn
%O A356434 0,1
%A A356434 _Peter Munn_, Aug 07 2022