[seqfan] Re: A006451 = n such that n*(n+1)/2+1 is square?
Joerg Arndt
arndt at jjj.de
Sun Oct 11 03:11:02 CEST 2009
The following message form Matthijs Coster
did not show up on on the list:
Hallo Joerg,
> Quick & dirty:
> ? for(k=0,20,q=0;for(n=1,10000,t=n*(n+1)/2+k;if(issquare(t),q=1;break()));
> if(q, print1(k,", ")))
Notice:
n(n+1)/2 + k = t^2
multiply by 8 then we have
(2n+1)^2 + (8k-7) = 2(2t)^2.
Substitute X for 2t and Y for 2n+1. We get the Pell-equation:
(*) 2X^2 - Y^2 = 8k-7
(*) can be solved if and only if the squarefree part of 8k-7 doesn't
contain factors congruent to 3 or 5 modulo 8.
Therefore the quick and dirty program can be improved by:
for (k = 1; k < K_0; k++)
{
n = 8*k-1;
factor(n,factors);
for (i = 0; i < factors.length; i++)
if (((factors[i].a % 8 == 3) || (factors[i].a % 8 == 5)) &&
(factors[i].b % 2 == 1))
result[k] = "no solution";
else
result[k] = "solution";
fprintf("%d %s\n", k, result[k]);
}
Greetings,
Matthijs Coster
[...]
More information about the SeqFan
mailing list