Contribution for Puzzlet #023

From:  Denis Borris [borrisd@ca.inter.net]


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)
Next f

Out of 9, 2 integer results will appear:
f=1: 11111
f=4: 10256

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.



MAIN MENU
CONTRIBUTIONS

Site design/maintenance: Dave Ellis E-mail me!
Last Updated: February 22nd, 2004.