Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Corrected recursive formula for number of primes

0 views
Skip to first unread message

James Harris

unread,
May 24, 2002, 9:09:25 PM5/24/02
to
The recursive formula for the number of primes below an even number
N>=18 is

N/2 - S where S is the sum of S_m from 0 to m_max for m's where 2m+3
is prime, where

S_0 = int((N-4)/6), S_m = int((N-4m^2 - 7m - 4)/(4m+6)), and

m_max = int(sqrt(8N-17)-7)/8.

So, for m_max = 2, S = S_0 + S_1 + S_2.

The first m that's dropped is m=3, since 2m+3 = 9, as it's not prime.

And the number of primes is N/2 - S.

Plugging in 24 for a quick test gives,

m_max = 0, S_0 = 3, which gives 9 primes.


James Harris

Uncle Al

unread,
May 24, 2002, 10:21:22 PM5/24/02
to
James Harris wrote:
>
> The recursive formula
[snip]

You don't know the meaning of "recursive." Uncle Al will help you,

http://www.mazepath.com/uncleal/sunshine.jpg
Recursive, cf: recursive.

Spewing idiot.

--
Uncle Al
http://www.mazepath.com/uncleal/
(Toxic URL! Unsafe for children and most mammals)
"Quis custodiet ipsos custodes?" The Net!

Dik T. Winter

unread,
May 24, 2002, 10:26:11 PM5/24/02
to
In article <3c65f87.02052...@posting.google.com> jst...@msn.com (James Harris) writes:
> N/2 - S where S is the sum of S_m from 0 to m_max for m's where 2m+3
> is prime, where

And how do we determine whether 2m+3 is prime or not?
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

Denis Feldmann

unread,
May 25, 2002, 2:03:11 AM5/25/02
to

"Dik T. Winter" <Dik.W...@cwi.nl> a écrit dans le message news:
GwnAr...@cwi.nl...

> In article <3c65f87.02052...@posting.google.com> jst...@msn.com
(James Harris) writes:
> > N/2 - S where S is the sum of S_m from 0 to m_max for m's where 2m+3
> > is prime, where
>
> And how do we determine whether 2m+3 is prime or not?

Well; at least there begin to be some justification that this formula is
indeed recursive.

David Kastrup

unread,
May 25, 2002, 3:15:33 AM5/25/02
to
jst...@msn.com (James Harris) writes:

> The recursive formula for the number of primes below an even number
> N>=18 is

[...]

Amazing, simply amazing. People have posted pi(n) for quite a few
large numbers, it would be child's work to verify something like the
above claim for the given cases.

How stupid must one be to keep spewing forth "corrections" for days
and days on end which keep missing the true values by orders of
magnitude, when the correct values are already given?

I knew that JSH was stupid, but his current streak of idiocy is even
surprising for his standards.

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David....@t-online.de

Rupert

unread,
May 25, 2002, 5:26:24 AM5/25/02
to
18 7 7
20 8 8
22 8 8
24 9 9
26 10 9
28 10 9
30 11 10
32 12 11
34 12 11
36 13 11
38 14 12
40 14 12
42 15 13
44 16 14
46 16 14
48 17 15
50 18 15
52 18 15
54 19 16
56 20 16
58 20 16
60 21 17
62 22 18
64 22 18
66 23 18
68 24 19
70 24 19
72 25 20
74 26 21
76 26 21
78 27 21
80 28 22
82 28 22
84 29 23
86 30 23
88 30 23
90 31 24
92 32 24

<snip>

Crossover here:

6208 813 807
6210 814 807
6212 815 808
6214 815 808
6216 815 808
6218 815 809
6220 787 809
6222 788 810
6224 788 810
6226 787 810

(I don't think there are any more crossovers but I didn't check)

<snip>

Peaks about here:

16100 1112 1874
16102 1112 1874
16104 1113 1875
16106 1113 1875
16108 1112 1875
16110 1113 1875
16112 1114 1876
16114 1070 1876
16116 1070 1876
16118 1070 1876
16120 1068 1876
16122 1069 1876
16124 1069 1876
16126 1069 1876
16128 1070 1877
16130 1071 1877
16132 1071 1877
16134 1072 1877

<snip>

Goes negative here:

40782 1 4269
40784 1 4269
40786 0 4269
40788 1 4270
40790 2 4270
40792 2 4270
40794 3 4270
40796 -1 4270

<snip>

100000 -6911 9592

Four hits. Unless there were some more crossovers.

Where do you get your drugs from? I want.

Moufang Loop

unread,
May 25, 2002, 6:17:44 AM5/25/02
to

"James Harris" <jst...@msn.com> wrote in message
news:3c65f87.02052...@posting.google.com...

> The recursive formula for the number of primes below an even number
> N>=18 is
>
> N/2 - S where S is the sum of S_m from 0 to m_max for m's where 2m+3
> is prime, where
>
> S_0 = int((N-4)/6), S_m = int((N-4m^2 - 7m - 4)/(4m+6)), and
>
...

Recursive?
As in S_n = function of S_{earlier m's}.
Wrong in any case.

ML

Rupert

unread,
May 25, 2002, 7:06:16 AM5/25/02
to
In the long run, the formula is approximately N/2-(N/4).log log N.

BTW, if you're going to have a sum of the form sum(1<=m<=m_max,2m+3
prime) S_m, I don't see what's wrong with sum(1<=m<=m_max,m prime) S_m
with m_max=n-1 and S_m=1. Got a much better hit rate, that one does.

Rupert

unread,
May 25, 2002, 7:20:10 AM5/25/02
to
Sorry, I mean N/2(1-log log N)

David C. Ullrich

unread,
May 25, 2002, 8:46:42 AM5/25/02
to
On 24 May 2002 18:09:25 -0700, jst...@msn.com (James Harris) wrote:

>The recursive formula for the number of primes below an even number
>N>=18 is
>
> N/2 - S where S is the sum of S_m from 0 to m_max for m's where 2m+3
>is prime, where

For heaven's sake. Even if the current version were _right_, don't
you see you utterly ridiculous this is? A "formula" for the number
of primes that involves only counting primes is just silly.

The point being that a much simpler formula is given by S = the
sum of 1, where the sum ranges over all m < N such that m is prime.

> S_0 = int((N-4)/6), S_m = int((N-4m^2 - 7m - 4)/(4m+6)), and
>
> m_max = int(sqrt(8N-17)-7)/8.
>
>So, for m_max = 2, S = S_0 + S_1 + S_2.
>
>The first m that's dropped is m=3, since 2m+3 = 9, as it's not prime.
>
>And the number of primes is N/2 - S.
>
>Plugging in 24 for a quick test gives,
>
> m_max = 0, S_0 = 3, which gives 9 primes.
>
>
>James Harris


David C. Ullrich

David C. Ullrich

unread,
May 25, 2002, 8:48:44 AM5/25/02
to
On 25 May 2002 09:15:33 +0200, David Kastrup
<David....@t-online.de> wrote:

>jst...@msn.com (James Harris) writes:
>
>> The recursive formula for the number of primes below an even number
>> N>=18 is
>
>[...]
>
>Amazing, simply amazing. People have posted pi(n) for quite a few
>large numbers, it would be child's work to verify something like the
>above claim for the given cases.
>
>How stupid must one be to keep spewing forth "corrections" for days
>and days on end which keep missing the true values by orders of
>magnitude, when the correct values are already given?
>
>I knew that JSH was stupid, but his current streak of idiocy is even
>surprising for his standards.

Yes it is - in fact you missed the stupdiest aspect of it. The
current version involves a sum over all m such that 2m + 3 is prime!
If we're allowed to use that kind of criterion there are simpler
formulas...

>--
>David Kastrup, Kriemhildstr. 15, 44793 Bochum
>Email: David....@t-online.de


David C. Ullrich

jmfb...@aol.com

unread,
May 25, 2002, 5:13:42 AM5/25/02
to
In article <3CEEF518...@hate.spam.net>,

Uncle Al <Uncl...@hate.spam.net> wrote:
>James Harris wrote:
>>
>> The recursive formula
>[snip]
>
>You don't know the meaning of "recursive." Uncle Al will help you,
>
>http://www.mazepath.com/uncleal/sunshine.jpg
>Recursive, cf: recursive.

One of these days, I'll have a system in my computer room
that can look at all that. My definition of recursive
formula is what comes out of my mouth when I'm debugging one.
'ey, Uncle. Good to see you're getting computes done.

/BAH

Subtract a hundred and four for e-mail.

David C. Ullrich

unread,
May 25, 2002, 9:26:19 AM5/25/02
to
On Sat, 25 May 02 09:13:42 GMT, jmfb...@aol.com wrote:

>In article <3CEEF518...@hate.spam.net>,
> Uncle Al <Uncl...@hate.spam.net> wrote:
>>James Harris wrote:
>>>
>>> The recursive formula
>>[snip]
>>
>>You don't know the meaning of "recursive." Uncle Al will help you,
>>
>>http://www.mazepath.com/uncleal/sunshine.jpg
>>Recursive, cf: recursive.
>
>One of these days, I'll have a system in my computer room
>that can look at all that.

You must know someone with a PC with a standard web
browser. Borrow it for a minute - you'll be glad you did.

>My definition of recursive
>formula is what comes out of my mouth when I'm debugging one.
>'ey, Uncle. Good to see you're getting computes done.
>
>/BAH
>
>Subtract a hundred and four for e-mail.


David C. Ullrich

Bengt Månsson

unread,
May 25, 2002, 1:20:29 PM5/25/02
to
James Harris wrote:

> The recursive formula for the number of primes below an even number
> N>=18 is
>
> N/2 - S where S is the sum of S_m from 0 to m_max for m's where 2m+3
> is prime, where
>
> S_0 = int((N-4)/6), S_m = int((N-4m^2 - 7m - 4)/(4m+6)), and
>
> m_max = int(sqrt(8N-17)-7)/8.


Should be m_max = int((sqrt(8N-17)-7)/8) I guess.

Then you need to test numbers up to roughly sqrt(N/2) to calculate
pi(N). That's somewhat better than Legendre's Formula which relies on
primes up to sqrt(N):

http://mathworld.wolfram.com/LegendresFormula.html

But _unlike your formula_ that formula is correct, it has been explored
to give better formulas (Meissel, Lehmert) and all this is 200 years old
or so.

> So, for m_max = 2, S = S_0 + S_1 + S_2.
>
> The first m that's dropped is m=3, since 2m+3 = 9, as it's not prime.
>
> And the number of primes is N/2 - S.
>
> Plugging in 24 for a quick test gives,
>
> m_max = 0, S_0 = 3, which gives 9 primes.


That's _one_ case, it tests only N/2 - int((N-4)/6) since m_max = 0, and
the result gets wrong already at N = 26.

--

___________________________________________________________________
Bengt Månsson, Partille, Sweden http://www.algonet.se/~bengtmn/
PhD Theoretical Physics, speciality Classical Fields and Relativity
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

jmfb...@aol.com

unread,
May 26, 2002, 5:00:56 AM5/26/02
to
In article <3cef90b9...@nntp.sprynet.com>,

ull...@math.okstate.edu (David C. Ullrich) wrote:
>On Sat, 25 May 02 09:13:42 GMT, jmfb...@aol.com wrote:
>
>>In article <3CEEF518...@hate.spam.net>,
>> Uncle Al <Uncl...@hate.spam.net> wrote:
>>>James Harris wrote:
>>>>
>>>> The recursive formula
>>>[snip]
>>>
>>>You don't know the meaning of "recursive." Uncle Al will help you,
>>>
>>>http://www.mazepath.com/uncleal/sunshine.jpg
>>>Recursive, cf: recursive.
>>
>>One of these days, I'll have a system in my computer room
>>that can look at all that.
>
>You must know someone with a PC with a standard web
>browser. Borrow it for a minute - you'll be glad you did.

Yup. Public libraries. Although I've noticed that other
people have "discovered" that libraries have them. Last year
I never had to wait; this year all terminals are busy.

The last time I looked at Uncle's stuff, I was just blown
away by his programmer's efficiency. That stuff just went
<whoosh!>. [emoticon shivering with delight]

Randy Poe

unread,
May 27, 2002, 1:04:31 PM5/27/02
to
On 24 May 2002 18:09:25 -0700, jst...@msn.com (James Harris)
wrote:

>The recursive formula for the number of primes below an even number

Why keep using 24 for a test? Don't you think it would be
wise to check other modest values where your "corrected"
formulas have broken down, like N=100 or 1000?

- Randy

0 new messages