View Single Post
Old 2011-04-22, 11:01   #24
Xitami
 
Apr 2010

168 Posts
Default

:) PARI/GP can write programs in C
Code:
ifelse(n,p,k)={ my(c);
	if(p<k,
		if(n>0,print);
	 	for(i=0,n,print1(" "));
		c=(p+k)>>1;
		print1("if(a1262["c"]<n)");  
		ifelse(n+1, c+1, k);
		for(i=0,n,print1(" "));
		print1("else");
		ifelse(n+1, p, c)
	,
		print(" return a1262["p"]==n;"); 
	);
}
fun(k)={
	print("int test(unsigned long long n) {");
	lt=eq=0;
	ifelse(0,1,k);
	print("} ");
}
fun(6)
Output (table is not necesary)
Code:
int test(unsigned long long n) {
 if(a1262[3]<n)
  if(a1262[5]<n) return a1262[6]==n;
  else
   if(a1262[4]<n) return a1262[5]==n;
   else return a1262[4]==n;
 else
  if(a1262[2]<n) return a1262[3]==n;
  else
   if(a1262[1]<n) return a1262[2]==n;
   else return a1262[1]==n;
}
only 2314 sprp to base 2 less then 2^32
only log2(2314)+1=12 tests in 2314*2 rows of programm

310 base 2 and 101 pseudoprimes below 145046817709

Last fiddled with by Xitami on 2011-04-22 at 11:16
Xitami is offline   Reply With Quote