Thursday, January 31, 2013

[hgwaaaip] Recursive Prime Predecessor Factorization code

Some Pari/GP code to calculate recursive prime predecessor factorization notation.

p(x)=if(x==2,print1(2),print1("(");f((x-1)/2);print1(")"))
Substitute x-1 for (x-1)/2 for uncompressed notation.

f(x)=my(n,m,c,r);n=factorint(x);m=matsize(n);for(r=1,m[1],for(c=1,n[r,2],p(n[r,1])))
Declaring statically scoped variables was important for recursion.

No comments :