Advertisement
algorithmuscanorj

Support program for the conjecture

Jan 3rd, 2013
3,009
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Original code for A055881 by: Joerg Arndt (www.jjj.de) Dec 2012
  2.  Sequencer adaptation for A196020 by: R. J. Cano, ( aallggoorriitthhmmuuss_at_gmail.com ), Jan 2013 */
  3. first_diff_mode=0;
  4. base=10;
  5. n=10; \\  Warning: n should not be greater than 10... never, if all computations are assumed in base-10;
  6. fc=vector(n) /* mixed radix numbers (rising factorial base) */
  7. ct=0; a=0; p=vector(n,k,k-1) /* permutation */
  8. t=0; j=0; w=#p; G=sum(y=1,w,p[y]*base^(w-y));
  9. updater()=
  10. {
  11.         ct += 1;
  12.         /* increment factorial number fc[]: */
  13.         j = 1;
  14.         while ( fc[j] == j,  fc[j]=0;  j+=1; );  /* scan over nines */
  15.         if ( j==n,  return() );  /* current is last */
  16.         fc[j] += 1;
  17.         /* update permutation p[], reverse prefix of length j+1: */
  18.         a = j;  /* next term of A055881 */
  19.         j += 1;  k = 1;
  20.         while ( k < j,
  21.             t=p[j]; p[j]=p[k]; p[k]=t;
  22.             k+=1; j-=1;
  23.         );
  24.     H=sum(y=1,w,p[y]*base^(w-y));
  25.         ans=(H-G)\(base-1);
  26.         if(first_diff_mode,G=H);
  27.     /* */
  28.     Qq=0;
  29.     while(ans%base==0, ans/=base; Qq++); \\ Useful for the checking of the "((p-1)!-1) Conjecture".
  30.         \\ Below return either ans or Qq depending of the attribute you want to know for a(n): The coefficient or the power.
  31.     /* * /
  32.         ans;
  33.     / * */I
  34.     /**/
  35.         Qq;  \\ Before enabling this, ensure that first_diff_mode is set to zero!.
  36.     /**/
  37. }
  38. if(!first_diff_mode, print("0")); for(u=1,(n!-1),print(updater()));
  39. quit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement