Need Patience!!calm down..
We get A(x) = (x + 3x2)/(1 - x - x2) = n is positive integer.
Then:
(n + 3)x2 + (n + 1)x - n = 0
D = 5n2 + 14n + 1 = m2 for some integer m.
Again we get:
5n2 + 14n - (m2 - 1) = 0
D = 5m2 + 44 = t2 for some integer t.
We get more general Pell's equation in the form t2 - 5m2 = 44.
I used http://mathworld.wolfram.com/PellEquation.html and http://en.wikipedia.org/wiki/Pell's_equation.
First solve "unit" form of this equation r2 - 5s2 = 1. First solution is (9, 4), then use recurence formula r(i + 1) = r(1)r(i) + 5s(1)s(i) and s(i + 1) = r(1)s(i) + s(1)r(i) to get all other solutions.
Then build set of soutions of t2 - 5m2 = 44 using it's set of fundamental solutions:{(t, m)} = {(7, 1), (8, 2), (13, 5), (17, 7), (32, 14), (43, 19)} and using the identity t2 - 5m2 = (t2 - 5m2)(r2 - 5s2) = (tr + 5ms)2 - 5(ts + mr)2 = 44. This gives tr + 5ms for the new value of t.
Finally, if t % 5 == 2 then n = (t - 7)/5 :)
My very simple program is:
Java
[hide code]
public class Problem140 {
public static void main(String[] args) {
long g, t, n;
long[] p = {7, 8, 13, 17, 32, 43};
long[] q = {1, 2, 5, 7, 14, 19};
long[] r = {9, 9, 9, 9, 9, 9};
long[] s = {4, 4, 4, 4, 4, 4}; int count = 5;
// First 5 values of n
long sum = 2 + 5 + 21 + 42 + 152; while (true) {
for (int k = 0; k < 6; k++) {
g = r[k];
r[k] = 9 * r[k] + 20 * s[k];
s[k] = 9 * s[k] + 4 * g;
t = p[k] * r[k] + 5 * q[k] * s[k]; if (t % 5 == 2) {
n = (t - 7) / 5;
sum += n;
count++;
System.out.println("n(" + count + ")=" + n);
if (count == 30) {
System.out.println("Sum=" + sum);
return;
}
}
}
}
}
}
Answer:
5673835352990