Contribution for Puzzlet #023
From: Denis Borris [email@example.com]
You can do that with 3 lines of code only, doing only 9 calculations.
You say to derive a formula, then use computer, so:
Let x = abcde; then fabcde = f*abcdef becomes:
10^5 * f + x = f * (10*x + f)
simplify to get:
x = (f * (10^5 - f)) / (10 * f - 1)
So now we only need to loop f from 1 to 9.
My Ubasic code:
For f = 1 to 9
Print (f * (10^5 - f)) / (10 * f - 1)
Out of 9, 2 integer results will appear:
Thanks, Denis. I had originally dismissed the "trivial" solution of 11111, but you're right to point it out - it's a
valid answer. Dave.