Advertisement
algorithmuscanorj

Slow PARI sequencer # 1 for A207324

Dec 28th, 2012
2,969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2.  
  3. (PARI) \\ R.J. Cano, Dec 7th 2012.
  4.  
  5. /*--> Proposed implementation for SJT algorithm <--*/
  6.  
  7. GreatestAllowedSize=11;
  8.  
  9. \\default(parisize, GreatestAllowedSize!*GreatestAllowedSize); \\ Please set it properly. Uncomment if necessary.
  10.  
  11. fromZero=0; \\ About count starting from 0 or 1.
  12.  
  13. f1(x)=(N-fromZero)*if((Mu[2]%2==0)&&((x-Mu[2]*Q[2])==N+Lambda[2]*(N-1)), c1=0; 1+f4(x), 0*(c1=1));
  14.  
  15. f2(x)=(N-fromZero)*if((Mu[2]%2==1)&&((x-Mu[2]*Q[2])%(N+1)==1), c2=0; 1+f4(x), 0*(c2=1));
  16.  
  17. f3(x)=if(c1*c2, ans=initial[Mu[1]*Q[1]+z]; if(m==(Q[2]-N) , Mu[1]++; m=1; z=1, m++; if(z==Q[1], z=1, z++)); ans);
  18.  
  19. f4(x)=0*if(Lambda[2]==N-1, Mu[2]++; Lambda[2]=0, Lambda[2]++);
  20.  
  21. SteinhausJhonsonTrotter(U)={initial=vector(1, w, w-fromZero); final=initial; N=1; while(N<U, N++; m=1; z=1; Q=[N-1, N^2]; Mu=[0, 0]; Lambda=[0, 0]; final=vector(N!*N, k, f1(k)+f2(k)+f3(k)); initial=final);
  22.  
  23. (final)};
  24.  
  25. /*----- VISUAL Sequencer for A207324: First 10, 000 terms ---------*/
  26.  
  27. Terms=10000;
  28.  
  29. groundOffset=0;
  30.  
  31. for(Beta=1, 9, tmpv=SteinhausJhonsonTrotter(Beta); for(kappa=1, Beta!*Beta, print(groundOffset+kappa, " ", tmpv[kappa]); if(groundOffset+kappa==Terms, quit(); )); groundOffset+=Beta!*Beta);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement