Re: [math-fun] Digit product proof
"David Wilson" <davidwwilson@comcast.net> wrote:
So, ostensibly, the smallest base-10 number with digit product 3628800 is 45578899(10).
Confirmed for that one instance.
Is the greedy algorithm correct for this problem?
No. I just brute-force tested it for bases 3 through 20 for digit products 1 through 5000. The first two bases for which any exceptions were found were 9 and 13. The first exception found was base 9, digit product 72, 266(9) by brute force, 338(9) by greedy. Here's my C code if anyone wants to play with it. The numbers output are all base 10, e.g. 222 and 278 rather than 266 and 338. Column 1 is 1 for matches, 0 for mismatches. #include <stdio.h> int main() { int b,d,g,i,i2,j,p,t,t2; for (b=3;b<21;b++) { for (t=1;t<5001;t++) { g = 0; t2 = t; p = 1; for (d=b-1;d>1;d--) { while (t2%d == 0) { t2 /= d; g += d*p; p *= b; } } if (t2 == 1) { j = 1; for (i=1;j!=t;i++) { i2 = i; j = 1; while (i2 && j) { j *= i2%b; i2 /= b; } } printf("%d b=%d t=%d %d %d\n",i-1==g,b,t,i-1,g); } } } return(0); }
participants (1)
-
Keith F. Lynch