Dan Asimov <asimov@msri.org> wrote:
Very interesting.
Thank you.
Which leads me to wonder what reciprocal integers look like in factorial base, where x ? (0, 1) is represented as
x = ? a_n / n!
where the sum is over n ? 2 with a_n ? Z+, 0 ? a_n < n, using the greedy algorithm.
I didn't understand most of that, due to -- as I've mentioned several times before -- non-ASCII characters being converted by this list's digest option into question marks, which makes lots of posts almost entirely incomprehensible. Here's my best guess as to what you were asking for. The first place after the point is 1/2!, the next place is 1/3!, the next place is 1/4!, etc. I only go to 20! since that's as far as 64-bit integers go. Also, my digits would soon run off the end of the alphabet. Note that in this base all rationals terminate. 1/2: 0.1 1/3: 0.02 1/4: 0.012 1/5: 0.0104 1/6: 0.01 1/7: 0.003206 1/8: 0.003 1/9: 0.00232 1/10: 0.0022 1/11: 0.002053140A 1/12: 0.002 1/13: 0.00141254850C 1/14: 0.001333 1/15: 0.0013 1/16: 0.00123 1/17: 0.001202368909270G 1/18: 0.00114 1/19: 0.001116209526BBD80I 1/20: 0.0011 Here's my code. It works right to left, placing all of 1/N in the 1/N! bin, then distributing as much of it as possible as far left as possible. #include <stdio.h> int main() { long long i,j,k,a[21],f[21]; char c; f[0] = 1; for (i=1;i<21;i++) f[i] = f[i-1]*i; for (i=2;i<21;i++) { for (j=0;j<21;j++) a[j] = 0; a[i] = f[i-1]; for (j=i-1;j;j--) { a[j] = a[j+1]/(j+1); a[j+1] %= (j+1); } for (j=0;j<21;j++) if (a[j]) k=j; printf("1/%lld: 0.",i); for (j=2;j<k+1;j++) { c = a[j]+48; if (c>57) c=a[j]+55; printf("%c",c); } printf("\n"); } return(0); } For my next trick I will calculate reciprocals of integers in negabinary (base -2). Remember, there are 110 kinds of people: Those who understand negabinary, and those who don't.