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!)
A013603 Difference between 2^n and the nearest prime less than or equal to 2^n. 16

%I #43 Oct 19 2022 06:37:43

%S 0,1,1,3,1,3,1,5,3,3,9,3,1,3,19,15,1,5,1,3,9,3,15,3,39,5,39,57,3,35,1,

%T 5,9,41,31,5,25,45,7,87,21,11,57,17,55,21,115,59,81,27,129,47,111,33,

%U 55,5,13,27,55,93,1,57,25,59,49,5,19,23,19,35,231,93,69,35,97,15

%N Difference between 2^n and the nearest prime less than or equal to 2^n.

%C If a(n) = 1, then n is prime and 2^n - 1 is a Mersenne prime. - _Franz Vrabec_, Sep 27 2005

%C Using the first variant A007917 (rather than A151799) of the prevprime() function, the sequence is well defined for n = 1, with a(1) = 2^1 - prevprime(2^1) = 2 - 2 = 0. - _M. F. Hasler_, Sep 09 2015

%C In Mathematica, one can use NextPrime with a second argument of -1 to obtain the next smaller prime. As almost all the powers of 2 are composite, this produces the proper results for most of this sequence. However, NextPrime[2, -1] returns -2 rather than the expected 2, which would consequently mean a(1) = 4 rather than 0. - _Alonso del Arte_, Dec 10 2016

%H T. D. Noe, <a href="/A013603/b013603.txt">Table of n, a(n) for n = 1..5000</a> (corrected by Sean A. Irvine, Jan 18 2019)

%H V. Danilov, <a href="https://web.archive.org/web/20060127010153/http://www.fortunecity.com/skyscraper/epson/276/pr1_2k.htm">Table for large n</a>.

%H Corbin Simpson, <a href="https://www.youtube.com/watch?v=LfepFANkz-k">2^255 - 19 and Elliptic Curve Cryptography (MegaFavNumbers)</a>, Youtube video (2020).

%F a(n) = A049711(2^n). - _R. J. Mathar_, Nov 28 2016

%F a(n) = 2^n - prevprime(2^n) = 2^n - prime(primepi(2^n)). - _Alonso del Arte_, Dec 10 2016

%p seq(2^i-prevprime(2^i),i=2..100);

%t {0} ~Join~ Array[With[{c = 2^#}, c - NextPrime[c, -1]] &, 80, 2] (* _Harvey P. Dale_, Jul 23 2013 *)

%t Table[2^n - Prime[PrimePi[2^n]], {n, 80}] (* _Alonso del Arte_, Dec 10 2016 *)

%o (PARI) a(n) = 2^n - precprime(2^n); \\ _Michel Marcus_, Apr 04 2020

%Y Cf. A013597, A014234, A049711, A007917, A151799.

%Y Equivalent sequence for next prime: A092131.

%K nonn

%O 1,4

%A James Kilfiger (mapdn(AT)csv.warwick.ac.uk)

%E Extended to a(1) = 0 by _M. F. Hasler_, Sep 09 2015

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 13 18:22 EDT 2024. Contains 372522 sequences. (Running on oeis4.)