Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Original code for A055881 by: Joerg Arndt (www.jjj.de) Dec 2012
- Sequencer adaptation for A196020 by: R. J. Cano, ( aallggoorriitthhmmuuss_at_gmail.com ), Jan 2013 */
- first_diff_mode=0;
- base=7;
- n=7; \\ Warning: n should not be greater than 10... never, if all computations are assumed in base-10;
- fc=vector(n) /* mixed radix numbers (rising factorial base) */
- ct=0; a=0; p=vector(n,k,k-1) /* permutation */
- t=0; j=0; w=#p; G=sum(y=1,w,p[y]*base^(w-y));
- updater()=
- {
- ct += 1;
- /* increment factorial number fc[]: */
- j = 1;
- while ( fc[j] == j, fc[j]=0; j+=1; ); /* scan over nines */
- if ( j==n, return() ); /* current is last */
- fc[j] += 1;
- /* update permutation p[], reverse prefix of length j+1: */
- a = j; /* next term of A055881 */
- j += 1; k = 1;
- while ( k < j,
- t=p[j]; p[j]=p[k]; p[k]=t;
- k+=1; j-=1;
- );
- H=sum(y=1,w,p[y]*base^(w-y));
- ans=(H-G)\(base-1);
- if(first_diff_mode,G=H);
- /* * /
- while(ans%base==0, ans/=base); \\ Useful for the checking of the "((p-1)!-1) Conjecture".
- / * */
- ans;
- }
- if(!first_diff_mode, print("0")); for(u=1,(n!-1),print(updater()));
- quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement