Find a geometric series of 3 or more positive integers, starting with 1, such that its sum is a perfect square.
See if you can find another such series.
(In reply to
re: Programming Solution by exoticorn)
You're right; I wrote the program quickly, expecting to find relatively small, workable numbers, then failed to consider the precision involved since all the numbers are integers.
I rewrote the program as follows to show the entire expansion and its sum, as well as the square of the located root for comparison. I used rlim==1 and nlim=30, so as to only show the first two 'accepted' solutions and the lowest 'big' solution found previously:
function display(r, n, root) {
var sum=0;
for (a=0; a<=n-1; a++) {
term=Math.pow(r,a);
document.write(term);
if (a<n-1)
document.write(" + ");
sum+=term;
}
var square=root*root;
document.write(" = " + sum + "<br>" + root + "² = "
document.write(square + "<br><br>");
}
var rlim=11
var nlim=30
for (r=2; r<=rlim; r++) {
for (n=3; n<=nlim; n++) {
test=Math.sqrt((Math.pow(r,n)-1)/(r-1));
if (test)==(Math.round(test)) {
display(r,n,test);
}
}
}
This yielded:
1 + 3 + 9 + 27 + 81 = 121
11² = 121
1 + 7 + 49 + 343 = 400
20² = 400
1 + 11 + 121 + 1331 + 14641 + 161051 + 1771561 + 19487171 + 214358881 + 2357947691 + 25937424601 + 285311670611 + 3138428376721 + 34522712143931 + 379749833583241 + 4177248169415651 + 45949729863572160 + 505447028499293760 + 5559917313492231000 + 61159090448414550000 + 672749994932560100000 + 7.400249944258161e+21 + 8.140274938683976e+22 + 8.954302432552373e+23 + 9.84973267580761e+24 + 1.0834705943388372e+26 + 1.191817653772721e+27 + 1.310999419149993e+28 + 1.4420993610649922e+29 + 1.5863092971714916e+30 = 1.7449402268886408e+30
1320961856712237² = 1.7449402268886406e+30
So indeed, the default precision of 16 places in javascript should account for the insane number of solutions the first program found, as well as the steady decline in the number of terms.
I don't know how to prove that those two soltions are unique, but it is certainly shown that they are the only sets of 'workable' numbers that work.
I really shouldn't tackle problems like this at 2am...
|
Posted by DJ
on 2003-07-15 05:41:05 |