Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
44
Task/Executable-library/PARI-GP/executable-library-1.parigp
Normal file
44
Task/Executable-library/PARI-GP/executable-library-1.parigp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include <pari/pari.h>
|
||||
|
||||
#define HAILSTONE1 "n=1;print1(%d,\": \");apply(x->while(x!=1,if(x/2==x\\2,x/=2,x=x*3+1);n++;print1(x,\", \")),%d);print(\"(\",n,\")\n\")"
|
||||
#define HAILSTONE2 "m=n=0;for(i=2,%d,h=1;apply(x->while(x!=1,if(x/2==x\\2,x/=2,x=x*3+1);h++),i);if(m<h,m=h;n=i));print(n,\": \",m)"
|
||||
|
||||
void hailstone1(int x)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
snprintf(buf, sizeof(buf), HAILSTONE1, x, x);
|
||||
|
||||
pari_init(1000000, 2);
|
||||
|
||||
geval(strtoGENstr(buf));
|
||||
|
||||
pari_close();
|
||||
}
|
||||
|
||||
void hailstone2(int range)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
snprintf(buf, sizeof(buf), HAILSTONE2, range);
|
||||
|
||||
pari_init(1000000, 2);
|
||||
|
||||
geval(strtoGENstr(buf));
|
||||
|
||||
pari_close();
|
||||
}
|
||||
|
||||
#if __i386__
|
||||
const char _hail[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2";
|
||||
#else // __x86_64__
|
||||
const char _hail[] __attribute__((section(".interp"))) = "/lib64/ld-linux-x86-64.so.2";
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
hailstone1(27);
|
||||
hailstone2(100000);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
void hailstone1(int);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
hailstone1(27);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue