mersenneforum.org Sums of all Squares
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

 2010-04-21, 11:28 #100 science_man_88     "Forget I exist" Jul 2009 Dumbassville 202618 Posts CRG I got gp2c but can't understand where the install is am I missing something ?
 2010-04-21, 12:26 #101 science_man_88     "Forget I exist" Jul 2009 Dumbassville 8,369 Posts
2:43:135:387:8711:20813:37717:66619:102723:155629:2397
31:335837:472741:640843:825747:1046653:1327559:1675661:2047767:2496671:30007
73:3533679:4157783:4846689:5638797:65796101:75997103:86606107:98055109:109936113:122705
127:138834131:155995137:174764139:194085149:216286151:239087157:263736163:290305167:318194173:348123
179:380164181:412925191:449406193:486655197:525464199:565065211:609586223:659315227:710844229:763285
233:817574239:874695241:932776251:995777257:1061826263:1130995269:1203356271:1276797277:1353526281:1432487
283:1512576293:1598425307:1692674311:1789395313:1887364317:1987853331:2097414337:2210983347:2331392349:2453193
353:2577802359:2706683367:2841372373:2980501379:3124142383:3270831389:3422152397:3579761401:3740562409:3907843
419:4083404421:4260645431:4446406433:4633895439:4826616443:5022865449:5224466457:5433315461:5645836463:5860205
467:6078294479:6307735487:6544904491:6785985499:7034986
webs.com might give you a subdomain just put it on there and go back to it every so often so the page doesn't get deleted lol Last fiddled with by science_man_88 on 2010-04-21 at 12:28
 2010-04-21, 12:45 #102 science_man_88     "Forget I exist" Jul 2009 Dumbassville 202618 Posts
907:37464550967:44505630977:46403000991:483513701009:503634601019:524279901217:872831701229:902893401237:933348701697:229106580
1753:2530038201777:2592556301801:2720722101823:2786752601847:2854392301867:2923882401873:2993970101879:3064507801913:3209291201933:328394370
1993:3517287601999:3597127702011:3677689002039:3842202802081:4013023802099:4187665602113:4276876502153:4551399602207:4742819802221:484112190
2239:4941294802251:5042275302269:5145151802281:5248846702341:5677153902351:5787510002371:5899280902381:6012473802389:6126333902399:624115040
2417:6357698502591:7487576202609:7622881502621:7760064802749:9210604603109:12812416303163:13205557703169:13406282203187:13609039503203:1381345640
3217:14019924103847:23771947603853:24068705703889:24670109503911:24975715203919:25282729703929:25590999403943:25900999504001:26533359704051:2782862730
4091:28492858304099:28828402804127:29167727304133:29509030604153:29852817904159:30198597204201:30549554504217:30904710604373:34585485204397:3497163010
4463:36548033704483:36949800205881:82208378106353:101863605106373:103484135306691:117209959306703:118108295406737:119917056406763:120831549306823:12360188400
6829:124534315706841:125469207406871:127354337606899:128304056506911:129258742206959:131186962006967:132156908106977:133129641806991:134106005507001:13508572560
7019:136070210907039:137059473407079:139054354407109:140064259307127:141079287007193:144160409707211:145199803407219:146241216707237:147287542807699:17648527780
7937:192418849507993:194955873708563:236073223908581:237544522808599:239023034908623:240507745008629:241996592708647:243490967608669:244992958908681:24649945980
8693:248010129508707:249524974008719:251044347308737:252570002608747:254099153508761:255632854808783:257174974108821:260281382708837:261842174008887:26655322670
8951:271336154608969:272943937909851:361707024509859:363650627809883:365601731109901:367559556809931:371497800609973:37546387960
heres the one I got for axn's code. this isn't exactly A174862 though I'd need to know how to modify it to make a table for that sequence. Last fiddled with by science_man_88 on 2010-04-21 at 12:56
2010-04-21, 13:57   #103
kar_bon

Mar 2006
Germany

22×23×31 Posts

It's very easy to read html-code here!

Perhaps you should do that like in the attachment!

(Delete the extension '.txt'!)
Attached Files
 SumSquares.htm.txt (5.7 KB, 81 views)

2010-04-21, 14:06   #104
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

202618 Posts

thanks I'll write it to a .htm.txt

print1("<table>\n<tr>");d=0;s=0;forprime(p=2,5000,s=s+p^2;d=d+1;print1("<td>"p ":"s"</td>");if(d==10,print1("</tr>\n<tr>");d=0));print1("</tr></table>")
that's how I made it. stuff like that. the other thing I wanted to attach was to big even when put to zip it's 1274KB of A024450
Attached Files
 axncode.htm.txt (119.3 KB, 283 views)

Last fiddled with by science_man_88 on 2010-04-21 at 15:03

 2010-04-21, 15:07 #105 science_man_88     "Forget I exist" Jul 2009 Dumbassville 8,369 Posts 1274 KB unzipped still was over 400 when zipped/RAR
2010-04-21, 23:03   #106
CRGreathouse

Aug 2006

2·2,969 Posts

Quote:
 Originally Posted by science_man_88 CRG I'd go with axn's if you don't plan to translate yafu my pari code is worse than axn's from what I have tried. his works faster so you could try that.
OK. Here's the gp2c result for
Code:
gp2c -g del.gp
using code
Code:
s=0;forprime(p=2,1000,s=s+p^2;if(Mod(s,10)==0, print(p, ":",s)))

Code:
/*-*- compile-command: "/usr/bin/gcc -c -o del.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -I"/usr/local/include" del.gp.c && /usr/bin/gcc -o del.gp.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -Wl,-shared del.gp.o -lc -lm -L"/usr/local/lib" -lpari"; -*-*/
#include <pari/pari.h>
/*
GP;install("init_del","v","init_del","./del.gp.so");
*/
void init_del(void);
/*End of prototype*/

static GEN s;
/*End of global vars*/

void
init_del(void)	  /* void */
{
pari_sp ltop = avma;
s = pol_x(fetch_user_var("s"));
s = gen_0;
{
pari_sp btop = avma;
long p = 0;
byteptr primepointer = diffptr;	  /* bptr */
if (1000 > maxprime())
pari_err(primer1);
for (;;)
{
if (p > 1000)
break;
s = gadd(s, sqri(stoi(p)));
if (gequal0(gmodulo(s, stoi(10))))
pariprintf("%ld:%Ps\n", p, s);
s = gerepileupto(btop, s);
}
}
s = gerepilecopy(ltop, s);
return;
}
and here's an improved (type-specialized, etc.) version:
Code:
/*-*- compile-command: "/usr/bin/gcc -c -o del.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -I"/usr/local/include" del.gp.c && /usr/bin/gcc -o del.gp.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -Wl,-shared del.gp.o -lc -lm -L"/usr/local/lib" -lpari"; -*-*/
#include <pari/pari.h>
/*
GP;install("init_del","v","init_del","./del.gp.so");
*/
void init_del(void);

void
init_del(void)
{
pari_sp ltop = avma;
GEN s = gen_0;
{
pari_sp btop = avma;
long p = 0;
byteptr primepointer = diffptr;	  /* bptr */
for (;;)
{
if (p > 1000)
break;
s = addis(s, p*p);
if (!smodis(s, 10))
pariprintf("%ld:%Ps\n", p, s);
s = gerepileupto(btop, s);
}
}
s = gerepilecopy(ltop, s);
return;
}
although technically,
Code:
  /*-*- compile-command: "/usr/bin/gcc -c -o del.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -I"/usr/local/include" del.gp.c && /usr/bin/gcc -o del.gp.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -Wl,-shared del.gp.o -lc -lm -L"/usr/local/lib" -lpari"; -*-*/
#include <pari/pari.h>
/*
GP;install("init_del","v","init_del","./del.gp.so");
*/
void init_del(void);

void
init_del(void)	  /* void */
{
pari_printf("907:37464550\n967:44505630\n977:46403000\n991:48351370");
}
is also an optimization...

Last fiddled with by CRGreathouse on 2010-04-21 at 23:43

 2010-04-22, 00:38 #107 science_man_88     "Forget I exist" Jul 2009 Dumbassville 8,369 Posts wow this is weird I don't find pari.h in my download ( which i haven't figured out how to install). this must be pari C as it seems to use only pari functions that I know of wish i got it in real C I know bytes.com has a forum for these languages but I'd rather be able to translate all this myself lol apparently assembly isn't fastest but can't you compile the C from there or get it fastest possible ?
 2010-04-22, 00:40 #108 science_man_88     "Forget I exist" Jul 2009 Dumbassville 8,369 Posts http://bytes.com/topic/c/answers/872...e-odd-divisors this was my first post there ( surprised it wasn't my last) maybe this can be used as the isprime() part of the pari code.
2010-04-22, 02:56   #109
CRGreathouse

Aug 2006

2·2,969 Posts

Quote:
 Originally Posted by science_man_88 wow this is weird I don't find pari.h in my download
It's part of Pari, not part of gp2c. gp2c just creates source code like what I posted.

Quote:
 Originally Posted by science_man_88 this must be pari C as it seems to use only pari functions that I know of wish i got it in real C
C doesn't support large numbers, so you either need to write routines to work with large numbers or use an existing library. In this case the code is using Pari's library.

Notice that in my modification of the code I changed the code in several places to do math directly in C rather than through the Pari library, in places where I knew the numbers would be small enough. (Actually for this program everything could be done in C, using Pari only for the list of primes. But that won't typically be the case.)

Of course if you know you will be working only with small numbers you might not need the Pari library. But in that case gp2c won't be useful to you.

Quote:
 Originally Posted by science_man_88 apparently assembly isn't fastest but can't you compile the C from there or get it fastest possible ?
The main problem with assembly is not speed but the time it takes to write and read it. Most of the time it's best to write in an easier language with just key parts in assembly.

Last fiddled with by CRGreathouse on 2010-04-22 at 02:57

2010-04-22, 03:12   #110
CRGreathouse

Aug 2006

2·2,969 Posts

Quote:
 Originally Posted by science_man_88 this was my first post there ( surprised it wasn't my last)
Your code only works below 2319529. It uses 32-bit signed integers, so even if you added the next 4623 primes you could only use it for numbers up to 2147483647.

To check the primes up to 18 quintillion, you would need to change to 64-bit unsigned integers and add 200915556 primes beyond what you'd need for the above. (This would bloat your source code to about 6 gigs if you drop spacing and indentation.) Checking a single (64-bit) number for primality with that algorithm would take about 2 seconds on a 3 GHz machine, so checking up to 18 quintillion would take about a quintillion seconds (most composites will drop out quickly.) Assuming you have a billion computers, this would take about 32 years.

Oh, and storing all the primes up to 18 quintillion (as a 64-bit uints) would take 2,953,910 terabytes. At current prices this would run a quarter-billion dollars to buy the storage (maybe less if you just want to rent).

Quote:
 Originally Posted by science_man_88 maybe this can be used as the isprime() part of the pari code.
Pari's code is much faster than yours for large numbers, and a bit faster for small numbers.

Last fiddled with by CRGreathouse on 2010-04-22 at 03:25

 Similar Threads Thread Thread Starter Forum Replies Last Post a1call Miscellaneous Math 42 2017-02-03 01:29 Nick Number Theory Discussion Group 0 2016-12-11 11:30 3.14159 Miscellaneous Math 12 2010-07-21 11:47 CRGreathouse Math 6 2009-11-06 19:20 m_f_h Puzzles 45 2007-06-15 17:46

All times are UTC. The time now is 20:22.

Wed Nov 25 20:22:47 UTC 2020 up 76 days, 17:33, 3 users, load averages: 1.84, 1.63, 1.60