algorithmuscanorj

http://www.oeis.org/A055881

Dec 15th, 2012
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. v055881(n)=
  3. /* Compute the first n! terms of A055881 by counting
  4.   in rising factorial base. */
  5. {
  6.     my( fc=vector(n) ); /* mixed radix numbers (rising factorial base) */
  7.     my( j=0 );
  8.     while ( 1,
  9.         /* increment factorial number fc[]: */
  10.         j = 1;
  11.         while ( fc[j] == j,  fc[j]=0;  j+=1; );  /* scan over nines */
  12.         if ( j==n,  return() );  /* current is last */
  13.         fc[j] += 1;
  14.         print1("  ", j );  /* A055881: position of rightmost change in fc[] */
  15.         print1("    ", fc);  /* show factorial number */
  16.         print();
  17.     );
  18. }  /* _Joerg Arndt_, Dec 15 2012 */
Add Comment
Please, Sign In to add comment