login
Prime closest to e^n.
5

%I #13 May 13 2013 01:54:04

%S 2,3,7,19,53,149,401,1097,2971,8101,22027,59879,162751,442399,1202603,

%T 3269011,8886109,24154957,65659969,178482289,485165237,1318815713,

%U 3584912833,9744803443,26489122147,72004899319

%N Prime closest to e^n.

%H Charles R Greathouse IV, <a href="/A037028/b037028.txt">Table of n, a(n) for n = 0..500</a>

%t NextPrime[ n_Integer ] := Module[ {k = n + 1}, While[ ! PrimeQ[ k ], k++ ]; Return[ k ] ]; PrevPrime[ n_Integer ] := Module[ {k = n - 1}, While[ ! PrimeQ[ k ], k-- ]; Return[ k ] ]; Do[ a = Round[ N[ E^n ] ]; b = NextPrime[ Round[ N[ E^n ] ] - 1 ]; c = PrevPrime[ Round[ N[ E^n ] ] + 1 ]; If[ b - N[ E^n ] > N[ E^n ] - c, Print[ c ], Print[ b ] ], {n, 0, 25} ]

%K nonn

%O 0,1

%A _G. L. Honaker, Jr._

%E Corrected and extended by _Robert G. Wilson v_, Sep 16 2000