There are two basic methods. The one usually called continued fractions starts with $a^2 < n,$ and continues with all $+$ signs. The other side would be the fairly modern method of Zagier, which uses all minus signs, and is discussed at length in his book on zeta functions, see also
https://oeis.org/A257161
The usual method is due, as far as I can tell, to Lagrange and Gauss; I admit that it is possible that continued fractions existed before the right-neighbor method. Here are some examples.
This one says that the CF for $\sqrt 7$ is $\langle 2; 1,1,1,4 \rangle,$ where the $1,1,1,4$ keeps repeating.
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell 7
0 form 1 4 -3 delta -1
1 form -3 2 2 delta 1
2 form 2 2 -3 delta -1
3 form -3 4 1 delta 4
4 form 1 4 -3
This one says that the CF for $\sqrt {29}$ is $\langle 5;2,1,1,2,10 \rangle,$ where the $2,1,1,2,10$ keeps repeating. In this case that part is repeated in the Lagrange cycle, which happens because there is a solution to $u^2 - 29 v^2 = -1$ in integers.
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./Pell 29
0 form 1 10 -4 delta -2
1 form -4 6 5 delta 1
2 form 5 4 -5 delta -1
3 form -5 6 4 delta 2
4 form 4 10 -1 delta -10
5 form -1 10 4 delta 2
6 form 4 6 -5 delta -1
7 form -5 4 5 delta 1
8 form 5 6 -4 delta -2
9 form -4 10 1 delta 10
10 form 1 10 -4