Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: next Prime method from sci.math post

  • To: mathgroup at
  • Subject: [mg52192] Re: [mg52168] next Prime method from sci.math post
  • From: DrBob <drbob at>
  • Date: Sun, 14 Nov 2004 04:30:48 -0500 (EST)
  • References: <>
  • Reply-to: drbob at
  • Sender: owner-wri-mathgroup at


The range of your f function includes most integers (10000 of the first 10042, for instance):

digits = 10000;
f[n_] := Floor[n + Log[n]^2/2]

{1,10042} OF COURSE the range includes most primes.

That is, most primes are f[n] for some n. (Using the word "most" very loosely.)

But here's an f function that doesn't miss any at all!!!



All primes fit that pattern, so I'm thinking of naming it the "Treat-Bagula prime finder function".

What do you think?


On Sat, 13 Nov 2004 04:40:19 -0500 (EST), Roger Bagula <tftn at> wrote:

> I read a post several days ago that said you could find a prime between
> n and n+Log[n]^2.
> ( there also seems to be a NextPrime[] function in Mathematica that I
> wasn't aware of)
> I tried the average of the two and it works very well
>  such that there are only a few primes that don't fit that pattern:
> (* Primes that aren't at the average of n and n+Log[n]^2 *)
> Clear[f]
> digits=10000
> f[n_]:=Floor[n+Log[n]^2/2]
> a=Delete[Union[Table[If[PrimeQ[f[n]]==True,f[n],0],{n,1,digits}]],1];
> b=Table[Prime[n],{n,1,Dimensions[a][[1]]}];
> Complement[b,a]
> {5,37,97,421,673,2659,3407,3847,7703}
> Respectfully, Roger L. Bagula
> tftn at, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 :
> alternative email: rlbtftn at
> URL :

DrBob at

  • Prev by Date: Re: TraditionalForm of expressions WITHOUT evaluating.
  • Next by Date: Re: Re: newbie question DSolve
  • Previous by thread: next Prime method from sci.math post
  • Next by thread: TraditionalForm of expressions WITHOUT evaluating.