Advertisement
algorithmuscanorj

Alternative SLOW sequencer for A215940

Jan 12th, 2013
2,546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (PARI) \\"Slow" sequencer program only for the first N! terms in a215940 (2<=N<=9)
  2. alphaperm(n, r)=if(n==1, r, r*10^(n-1)+alphaperm(n-1, r+1));
  3. omegaperm(n)=if(n==1, 1, n*10^(n-1)+omegaperm(n-1));
  4. factoromu(n, k)=if(k==0, 1, {ans=1; while(((k-ans)%10!=0), ans++); ans*factoromu(n, (k-ans)/10)})
  5. factorosu(n, k)=if(k==0, 0, {ans=1; while(((k-ans)%10!=0), ans++); ans^2+factorosu(n, (k-ans)/10)})
  6. b215940(lambda)= {
  7. A=alphaperm(lambda, 1);
  8. B=omegaperm(lambda);
  9. C=lambda!;
  10. D=lambda^3/3+lambda^2/2+lambda/6;
  11. for(y=0, (B-A)/9, if( (factoromu(lambda, 9*y+A)==C) && (factorosu(lambda, 9*y+A)==D) , print(y), 0));
  12.  
  13. } \\ - This routine verifies 3 mathematical properties of permutations without repetitions.
  14.   print("Example: The call b215940(4); returns, ");
  15.   b215940(4);
  16. quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement