Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg52192] Re: [mg52168] next Prime method from sci.math post
  • From: DrBob <drbob at bigfoot.com>
  • Date: Sun, 14 Nov 2004 04:30:48 -0500 (EST)
  • References: <200411130940.EAA01018@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

Roger,

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

Clear[f]
digits = 10000;
f[n_] := Floor[n + Log[n]^2/2]
z=f/@Range@digits;
Length@z
Through[{Min,Max}@z]

10000
{1,10042}

...so 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!!!

Clear[f]
digits=10000;
f[n_]:=n
a=Rest@Union@Table[If[PrimeQ@f@n,f[n],0],{n,1,digits}];
b=Prime@Range@Length@a;
Complement[b,a]

{}

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

What do you think?

Bobby

On Sat, 13 Nov 2004 04:40:19 -0500 (EST), Roger Bagula <tftn at earthlink.net> 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 earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 :
> alternative email: rlbtftn at netscape.net
> URL :  http://home.earthlink.net/~tftn
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • 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.