Solve : $x^2-92 y^2=1$ As some of you might know,this is Brahmagupta's equation . How to find solution for this ? 
I mean integral solution? How to solve it using programming ? 
I tried something like $x^2=1+92y^2$
$x=\sqrt{1+92y^2}$
Use brute force approach to check for every y ? Is there any better answer ?
 A: I think the most common systematic way to solve this type of problem is using continued fractions. I'll reiterate @Quimey's suggestion to refer to Wikipedia for Pell's Equation
and specifically the section "Fundamental solution via continued fractions" and the Lenstra paper cited there.
In this case as a periodic continued fraction
$$
\sqrt{92} = [9;1,1,2,4,2,1,1,18,1,1,2\ldots] = 9+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{2+\cfrac{1}{4+\cfrac{1}{2+\cdots}}}}}
$$
and after 7 terms we get the approximation $\sqrt{92}\simeq 1151/120$ which gives the fundamental solution.
As for implementing an algorithm for finding the continued fraction for square roots, you should be able to find resources online with a search, but can start by taking a look at this question.
A: As for the programming part, I thought I'd put up some simple brute force Python just as an example.
# Start at (1, 1) because (1, 0) is a trivial solution
x, y = 1, 1
z = x**2 - 92*(y**2)

while z != 1:
    if z > 1:
        y += 1
    else:
        x += 1

    z = x**2 - 92*(y**2)

print x, y

This outputs the first solution
1151 120

Of course, as a brute force solution this code won't get you very far if, for example, you replaced 92 with larger numbers (or even if you replaced it by 61, for that matter).
A: The key is a (kind of) miraculous identity: $(x_1^2 - Ny_1^2)(x_2^2 - Ny_2^2)=(x_1x_2 + Ny_1y_2) - N(x_1y_2 + x_2y_1)^2$.
This means that if $x_1^2 - Ny_1^2 = k_1$ and $x_2 - Ny_2^2 = k_2$, then $(x_1x_2 + Ny_1y_2) - N(x_1y_2 + x_2y_1)^2 = k_1k_2$.
We can rewrite this in the following way: if $(x_1,y_1,k_1)$ and $(x_2,y_2,k_2)$ satisfy $x^2-92y^2 = k$, then $(x_1x_2 + Ny_1y_2,x_1y_2 + x_2y_1, k_1k_2)$ is also a solution. This operation is called "composing".
Now it is obvious that $(10,1,8)$ is one such triple satisfying $x^2 - 92y^2 = k$. We can compose $(10,1,8)$ with $(10,1,8)$ to get the triple $(192, 20, 64)$ and divide $x$ and $y$ by $8$ (so that $k$ is reduced by a factor of $64$), so that we have $(24, \frac{5}{2}, 1)$. Composing this with itself again, we have the solution $(1151, 120, 1)$.
