mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Puzzles (https://www.mersenneforum.org/forumdisplay.php?f=18)
-   -   Sums of all Squares (https://www.mersenneforum.org/showthread.php?t=13181)

 CRGreathouse 2010-03-30 17:27

[QUOTE=bsquared;210073]I guess I was thinking of a link to tables, or something. But that would require me to generate and host those tables. I'll save that for some day when I'm bored ;)[/QUOTE]

Maybe you can submit a sequence of every millionth term or something. Not exactly classy, but it has precedent (A080128, say).

76304519151822049179, 671924965564646162227, 2393465488665494654963, 5889405149040404480379, 11834774513923727795971, 20925456417823033330259, ...

 bsquared 2010-03-30 19:00

[QUOTE=CRGreathouse;210078]Right. You could do two modili at a time without much penalty, though, with appropriate lookup tables and bit operations. Note that you only need to compare (and hence reduce) every 8 primes, each term (other than the first) has index = 5 (mod 8).[/QUOTE]

I just realized my code to do the sum of prime squares routines was hugely inefficient, in that I was using YAFU's built in arbitrary precision functions to do the squaring and summing. In reality we only need fixed precision of, say, 3 64 bit limbs (192 bits should be plenty to represent the sum). Implementing this made my sum of prime squares routine about 35 times faster.

I also store the highest power of 2 dividing the power of 10 modulus, which makes for a very quick pre-test of divisibility by 10 (logical AND followed by a predictable branch) and makes full precision divisions *extremely* rare. Doing things this way is actually faster than using pure modular arithmetic, since we almost never have to perform a division.

As a side benefit, it's easy to build tables of prime sums, or prime square sums, and we also don't have to restart a sum to test for a new power of 10 modulus.

 bsquared 2010-03-30 19:02

[QUOTE=CRGreathouse;210079] Not exactly classy ...[/QUOTE]

Right up my alley, then :smile:

 bsquared 2010-03-30 19:43

I must have some sort of tinkerers disease... can't leave well enough alone.

This disease was causing me to be offended by how long it was taking to compute the primes in a range of 1e9. So I tinkered... and doubled the speed :smile:

before:
[CODE]found 40609038 primes in range 49000000000 to 50000000000 in elapsed time = 5.4835
**** 49460594569 is 0 mod 1410065408 ****
sum of squares complete in elapsed time = 6.8852, sum is 1714863031171407826702942323341
[/CODE]

after:
[CODE]found 40609038 primes in range 49000000000 to 50000000000 in elapsed time = 2.8866
**** 49460594569 is 0 mod 10000000000 ****
sum of squares complete in elapsed time = 0.1639, sum is 1714863031171407826702942323341
[/CODE]

which of course is completely useless, but now I feel better.

 davar55 2010-03-30 20:00

This is fine work by all of you. If you wish to submit the sequence to
oeis, please go ahead. I couldn't do justice to the calculations, which
I'm really impressed by. Joint discovery (attribution) is fine.

 CRGreathouse 2010-03-30 20:14

[QUOTE=davar55;210100]I couldn't do justice to the calculations, which
I'm really impressed by.[/QUOTE]

I'll echo this. I just used a one-line Pari script to discover mine. :smile:

 bsquared 2010-04-02 14:41

Now in OEIS: [URL="http://www.research.att.com/~njas/sequences/A174862"]A174862[/URL]

 davar55 2010-04-06 20:28

With all the work done on the OP, it shouldn't be too hard
to generalize the problem a bit.

I think cubes.

2^3 + 3^3 + 5^3 + ... + p^3 = 10[sup]m[/sup]K

What is the smallest prime p such that
the sum of cubes of all primes up to p
is a multiple of 10 (or 100 or 1000 or 10000 or ...).

I'm also curious about how these (squares and cubes) results
compare to first powers (sum of primes themselves).

Since these series depend on the properties of a number
in base ten, they could be considered recreational --
interesting but not necessarily useful. Still, perhaps the
sequence of sequences can someday be used to derive some
important number theoretic fact. That's one of the purposes
of the oeis.

 petrw1 2010-04-06 22:33

[QUOTE=davar55;210785]I'm also curious about how these (squares and cubes) results compare to first powers (sum of primes themselves).[/QUOTE]

A start on the first powers for the first 6,000,000 primes - p<=104,395,301

5 10
23 100
35677 63731000
106853 515530000
632501 15570900000

 bsquared 2010-04-06 22:36

[QUOTE=petrw1;210796]A start on the first powers for the first 1,000,000 primes - p<=15,485,863

5 10
23 100
35677 63731000
106853 515530000
632501 15570900000[/QUOTE]

 petrw1 2010-04-06 22:44