[Question]
  [
Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated [Pell equation](https://en.wikipedia.org/wiki/Pell%27s_equation)
$$x^2 - n\cdot y^2 = 1$$
### Details
* The fundamental \$(x,y)\$ is a pair of integers \$x,y\$ satisfying the equation where \$x\$ is minimal, and positive. (There is always the trivial solution \$(x,y)=(1,0)\$ which is not counted.)
* You can assume that \$n\$ is not a square.
### Examples
```
 n           x    y
 1           -    -
 2           3    2
 3           2    1
 4           -    -
 5           9    4
 6           5    2
 7           8    3
 8           3    1
 9           -    -
10          19    6
11          10    3
12           7    2
13         649    180
14          15    4
15           4    1
16           -    -
17          33    8
18          17    4
19         170    39
20           9    2
21          55    12
22         197    42
23          24    5
24           5    1
25           -    -
26          51    10
27          26    5
28         127    24
29        9801    1820
30          11    2
31        1520    273
32          17    3
33          23    4
34          35    6
35           6    1
36           -    -
37          73    12
38          37    6
39          25    4
40          19    3
41        2049    320
42          13    2
43        3482    531
44         199    30
45         161    24
46       24335    3588
47          48    7
48           7    1
49           -    -
50          99    14
51          50    7
52         649    90
53       66249    9100
54         485    66
55          89    12
56          15    2
57         151    20
58       19603    2574
59         530    69
60          31    4
61  1766319049    226153980
62          63    8
63           8    1
64           -    -
65         129    16
66          65    8
67       48842    5967
68          33    4
69        7775    936
70         251    30
71        3480    413
72          17    2
73     2281249    267000
74        3699    430
75          26    3
76       57799    6630
77         351    40
78          53    6
79          80    9
80           9    1
81           -    -
82         163    18
83          82    9
84          55    6
85      285769    30996
86       10405    1122
87          28    3
88         197    21
89      500001    53000
90          19    2
91        1574    165
92        1151    120
93       12151    1260
94     2143295    221064
95          39    4
96          49    5
97    62809633    6377352
98          99    10
99          10    1
```
Relevant OEIS sequences: [A002350](https://oeis.org/A002350) [A002349](https://oeis.org/A002349) [A033313](https://oeis.org/A033313) [A033317](https://oeis.org/A033317)
  
[Answer]
# [Piet](http://www.dangermouse.net/esoteric/piet.html), 612 codels
Takes *n* from standard input. Outputs *y* then *x*, space-separated.
Codel size 1: [![Pell's equation program with codel size 1](https://i.stack.imgur.com/iP0yG.png)](https://i.stack.imgur.com/iP0yG.png)
Codel size 4, for easier viewing: [![Pell's equation program with codel size 1](https://i.stack.imgur.com/B4t3B.png)](https://i.stack.imgur.com/B4t3B.png)
## Explanation
Check out [this NPiet trace](https://i.stack.imgur.com/GnXxc.png), which shows the program calculating the solution for an input value of 99.
I'm not sure whether I'd ever heard of Pell's equation before this challenge, so I got all of the following from Wikipedia; specifically, these sections of three articles:
* [Pell's equation § Fundamental solution via continued fractions](https://en.wikipedia.org/wiki/Pell%27s_equation#Fundamental_solution_via_continued_fractions)
* [Methods of computing square roots § Continued fraction expansion](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Continued_fraction_expansion)
* [Continued fraction § Infinite continued fractions and convergents](https://en.wikipedia.org/wiki/Continued_fraction#Infinite_continued_fractions_and_convergents)
Basically, what we do is this:
1. Get \$n\$ from standard input.
2. Find \$\lfloor\sqrt n\rfloor\$ by incrementing a counter until its square exceeds \$n\$, then decrement it once. (This is the first loop you can see in the trace, at top left.)
3. Set up some variables for calculating \$x\$ and \$y\$ from the continued fraction of \$\sqrt n\$.
4. Check whether \$x\$ and \$y\$ fit Pell's equation yet. If they do, output the values (this is the downwards branch about 2/3 of the way across) and then exit (by running into the red block at far left).
5. If not, iteratively update the variables and go back to step 4. (This is the wide loop out to the right, back across the bottom, and rejoining not quite halfway across.)
I frankly have no idea whether or not a brute-force approach would be shorter, and I'm not about to try it! [Okay, so I tried it.](https://codegolf.stackexchange.com/a/183368/13959)
[Answer]
# [Piet](http://www.dangermouse.net/esoteric/piet.html), 184 codels
This is the brute-force alternative I said (in [my other answer](https://codegolf.stackexchange.com/a/183329/13959)) that I didn't want to write. It takes over 2 minutes to compute the solution for *n* = 13. I really don't want to try it on *n* = 29... but it checks out for every *n* up to 20, so I'm confident that it's correct.
Like that other answer, this takes *n* from standard input and outputs *y* then *x*, space-separated.
Codel size 1: [![Pell's equation program (brute-force variant) with codel size 1](https://i.stack.imgur.com/txxr0.png)](https://i.stack.imgur.com/txxr0.png)
Codel size 4, for easier viewing: [![Pell's equation program (brute-force variant) with codel size 4](https://i.stack.imgur.com/vB634.png)](https://i.stack.imgur.com/vB634.png)
## Explanation
Here's the [NPiet trace](https://i.stack.imgur.com/zUmrH.png) for an input value of 5.
This is the most brutal of brute force, iterating over both \$x\$ and \$y\$. Other solutions might iterate over \$x\$ and then calculate \$y=\sqrt{\frac{x^2-1}{n}}\$, but they're *wimps*.
Starting from \$x=2\$ and \$y=1\$, this checks whether \$x\$ and \$y\$ have solved the equation yet. If it has (the fork at the bottom near the right), it outputs the values and exits.
If not, it continues left, where \$y\$ is incremented and compared to \$x\$. (Then there's some direction-twiddling to follow the zig-zag path.)
This last comparison is where the path splits around the mid-left. If they're equal, \$x\$ is incremented and \$y\$ is set back to 1. And we go back to checking if it's a solution yet.
I still have some whitespace available, so maybe I'll see if I can incorporate that square-root calculation without enlarging the program.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 16 bytes
```
;1↔;Ċz×ᵐ-1∧Ċ√ᵐℕᵐ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/39rwUdsU6yNdVYenP9w6QdfwUcfyI12POmYBOY9apgLJ///NTf5HAQA "Brachylog – Try It Online")
### Explanation
```
;1↔                Take the list [1, Input]
   ;Ċz             Zip it with a couple of two unknown variables: [[1,I],[Input,J]]
      ×ᵐ           Map multiply: [I, Input×J]
        -1         I - Input×J must be equal to 1
          ∧        (and)
           Ċ√ᵐ     We are looking for the square roots of these two unknown variables
              ℕᵐ   And they must be natural numbers
                   (implicit attempt to find values that match those constraints)
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 34 bytes
PARI/GP almost has a built-in for this: `quadunit` gives the [fundamental unit](https://en.wikipedia.org/wiki/Fundamental_unit_(number_theory)) of the [quadratic field](https://en.wikipedia.org/wiki/Quadratic_field) \$\mathbb{Q}(\sqrt{D})\$, where \$D\$ is the [discriminant](https://en.wikipedia.org/wiki/Discriminant_of_an_algebraic_number_field) of the field. In other words, `quadunit(4*n)` solves the Pell's equation \$x^2 - n \cdot y^2 = \pm 1\$. So I have to take the square when its norm is \$-1\$.
I don't know what algorithm it uses, but it even works when \$n\$ is not square-free.
Answers are given in the form `x + y*w`, where `w` denotes \$\sqrt{n}\$.
```
n->(a=quadunit(4*n))*a^(norm(a)<0)
```
[Try it online!](https://tio.run/##DYtBCoAwDAS/Ej0l0kILHtWnCAGt5GCsUd9fs4c5DLOVTeJRW4EZmsYFeb4/3j6VF8dBiQZeUS87kWlK1MplqN7mADmlAFKwk@fxj@2oFKCa6OtJD3FxFJe@9gM "Pari/GP – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 46 bytes
```
FindInstance[x^2-y^2#==1&&x>1,{x,y},Integers]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2773y0zL8Uzr7gkMS85Nboizki3Ms5I2dbWUE2tws5Qp7pCp7JWxzOvJDU9tag4Vu1/QFFmXomCQ3q0mWHs//8A "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~17~~ ~~16~~ 14 bytes
Saved a byte thanks to *Kevin Cruijssen*.  
Outputs `[y, x]`
```
∞.Δn*>t©1%_}®‚
```
[Try it online!](https://tio.run/##yy9OTMpM/f//Ucc8vXNT8rTsSg6tNFSNrz207lHDrP//LY0B "05AB1E – Try It Online")
**Explanation**
```
∞                 # from the infinite list of numbers [1 ...]
 .Δ        }      # find the first number that returns true under
   n              # square
    *             # multiply with input
     >            # increment
      t©          # sqrt (and save to register as potential x)
        1%        # modulus 1
          _       # logical negation
            ®‚    # pair result (y) with register (x)
```
[Answer]
# Java 8, ~~74~~ ~~73~~ 72 bytes
```
n->{int x=1;var y=.1;for(;y%1>0;)y=Math.sqrt(-x*~++x/n);return x+" "+y;}
```
-1 byte thanks to *@Arnauld*.  
-1 byte thanks to *@OlivierGrégoire*.
[Try it online.](https://tio.run/##RY/BTsMwEETv/YolUiUHKyZB6gXj/kF74QgcjOOAS@oUexPFqsKvhw0t4rLWeux5Mwc96OJQf86m1THCTjt/XgE4jzY02ljYLyvAEwbn38GwuuvfWgs@l3Q/rWhE1OgM7MGDgtkX2zP9hlFVctABkhKVbLrAZFpX21LmSe00foj4FZAV4@035@MduQWLffAw8gwynuQ0y8X7RDDyviKGztVwpIjsEuf5FXR@ybcQFqxT9xLco9qUdHCe/4rUp2H/VJevqxtV/mlULkW0R9H1KE7ki61njmcPL5hxLwy9v5ad5h8)
**Explanation:**
```
n->{                 // Method with double parameter and string return-type
  int x=1;           //  Integer `x`, starting at 1
  var y=.1;          //  Double `y`, starting at 0.1
  for(;y%1>0;)       //  Loop as long as `y` contains decimal digits:
    y=               //   Set `y` to:
      Math.sqrt(     //    The square-root of:
        -x*          //     Negative `x`, multiplied by
           ~++x      //     `(-x-2)` (or `-(x+1)-1)` to be exact)
                     //     (because we increase `x` by 1 first with `++x`)
               /n);  //     Divided by the input
  return x+" "+y;}   //  After the loop, return `x` and `y` with space-delimiter as result
```
[Answer]
# R,  ~~66~~ ~~56~~ ~~54~~ ~~53~~ ~~52~~ ~~47~~ 45 bytes
a full program
```
n=scan();while((x=(1+n*T^2)^.5)%%1)T=T+1;x;+T
```
~~-1 -2~~  thanks to @Giuseppe
-7 thanks to @Giuseppe & @Robin Ryder
-2 @JAD
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 40 bytes
```
½©%1İ$<®‘¤$Ð¿¹;Ḋ$LḂ$?Ḟṭ@ṫ-ṚZæ.ʋ¥ƒØ.,U¤-ị
```
[Try it online!](https://tio.run/##AW8AkP9qZWxsef//wr3CqSUxxLAkPMKu4oCYwqQkw5DCv8K5O@G4iiRM4biCJD/huJ7hua1A4bmrLeG5mlrDpi7Ki8KlxpLDmC4sVcKkLeG7i/8s4oCcIC0@IOKAnSzDh8WS4bmYJAoxNTBSw4figqxZ//8 "Jelly – Try It Online")
An alternative Jelly answer, less golfy but more efficient algorithmically when x and y are large. This finds the convergents of the regular continued fraction that approximate the square root of n, and then checks which solve the Pell equation. Now correctly finds the period of the regular continued fraction. 
Thanks to @TimPederick, I’ve also implemented an integer-based solution which should handle any number:
# [Jelly](https://github.com/DennisMitchell/jelly), 68 bytes
```
U×_ƭ/;²®_$÷2ị$}ʋ¥µ;+®Æ½W¤:/$$
¹©Æ½Ø.;ÇƬṪ€F¹;Ḋ$LḂ$?ṭ@ṫ-ṚZæ.ʋ¥ƒØ.,U¤-ị
```
[Try it online!](https://tio.run/##AaIAXf9qZWxsef//VcOXX8atLzvCssKuXyTDtzLhu4skfcqLwqXCtTsrwq7DhsK9V8KkOi8kJArCucKpw4bCvcOYLjvDh8as4bmq4oKsRsK5O@G4iiRM4biCJD/hua1A4bmrLeG5mlrDpi7Ki8KlxpLDmC4sVcKkLeG7i/8ww4fDhsKyPwos4oCcIC0@IOKAnSzDh8WS4bmYJAo1MDBSw4figqxZ//8 "Jelly – Try It Online")
For example, the [solution for 1234567890](https://tio.run/##AYYAef9qZWxsef//VcOXX8atLzvCssKuXyTDtzLhu4skfcqLwqXCtTsrwq7DhsK9V8KkOi8kJArCucKpw4bCvcOYLjvDh8as4bmq4oKsRsK5O@G4iiRM4biCJD/hua1A4bmrLeG5mlrDpi7Ki8KlxpLDmC4sVcKkLeG7i//Dh///MTIzNDU2Nzg5MA) has 1936 and 1932 digits for the numerator and denominator respectively. 
[Answer]
# JavaScript (ES7), 47 bytes
```
n=>(g=x=>(y=((x*x-1)/n)**.5)%1?g(x+1):[x,y])(2)
```
[Try it online!](https://tio.run/##DchBDoIwEEbhPaf4N5CZFqo14kKtHsS4IAgEQ6YGjCkxnr12877kPZtPs7Tz@HpX4h9d7F0Ud6HBhdTVEQUVKssbYaVMzbm9DhS05eMtlOudacex9zMJHOwJgjP2h6TWjG@GNJTC1tTIYVEUaL0sfurM5AeSEj0Jc/aLfw "JavaScript (Node.js) – Try It Online")
Below is an alternate **49-byte** version which keeps track of \$x²-1\$ directly instead of squaring \$x\$ at each iteration:
```
n=>[(g=x=>(y=(x/n)**.5)%1?1+g(x+=k+=2):2)(k=3),y]
```
[Try it online!](https://tio.run/##DcjBCoJAEAbgu0/xX5KZXbPWskM19iDRQUyllNnQCCV69s3TB9@z/JRjNTxe77X6ex0aCSrFlVqZpKBZaNooG5PmvHIXZ1uarHRWMj5mTJ3sOJlvofEDKQTuBMUZ@8OitYxvhCWMwTbNsYJDHKPyOvq@TnvfkiZoSJmjX/gD "JavaScript (Node.js) – Try It Online")
Or we can go the non-recursive way for **50 bytes**:
```
n=>eval('for(x=1;(y=((++x*x-1)/n)**.5)%1;);[x,y]')
```
[Try it online!](https://tio.run/##FcpBDoIwEEbhPaf4N8BMC2gXuKn1IsYFQTCaZkrAkBLj2ausXvLlvbq1W/r5Ob1rCfchjS6Juwxr56kcw0zRGUubI9I6qlgbPggr1bScG8v2GqvtVnLaT4GDsRCccdqrNeOT4Q9K4di0yGFQFOiDLMEPjQ8PkgojCXP2TT8 "JavaScript (Node.js) – Try It Online")
[Answer]
# TI-BASIC, ~~44~~ ~~42~~ 41 bytes
```
Ans→N:"√(N⁻¹(X²-1→Y₁:1→X:Repeat not(fPart(Ans:X+1→X:Y₁:End:{X,Ans
```
Input is \$n\$.  
Output is a list whose values correspond to \$(x,y)\$.
Uses the equation \$y=\sqrt{\frac{x^2-1}{n}}\$ for \$x\ge2\$ to calculate the fundamental solution.  
The current \$(x,y)\$ pair for that equation is a fundamental solution iff \$y\bmod1=0\$.
**Examples:**
```
6
               6
prgmCDGF12
           {5 2}
10
              10
prgmCDGF12
          {19 6}
13
              13
prgmCDGF12
       {649 180}
```
**Explanation:**
```
Ans→N:"√(N⁻¹(X²+1→Y₁:1→X:Repeat not(fPart(Ans:X+1→X:Y₁:End:{X,Ans  ;full logic
Ans→N                                                              ;store the input in "N"
      "√(N⁻¹(X²+1→Y₁                                               ;store the aforementioned
                                                                   ; equation into the first
                                                                   ; function variable
                     1→X                                           ;store 1 in "X"
                         Repeat not(fPart(Ans          End         ;loop until "Ans" is
                                                                   ; an integer
                                              X+1→X                ;increment "X" by 1
                                                    Y₁             ;evaluate the function
                                                                   ; stored in this variable
                                                                   ; at "X" and leave the
                                                                   ; result in "Ans"
                                                           {X,Ans  ;create a list whose
                                                                   ; values contain "X" and
                                                                   ; "Ans" and leave it in
                                                                   ; "Ans"
                                                                   ;implicitly print "Ans"
```
---
**Note:** TI-BASIC is a tokenized language. Character count does ***not*** equal byte count.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 17 bytes
```
`@:Ut!G*-!1=&fts~
```
[Try it online!](https://tio.run/##y00syfn/P8HBKrRE0V1LV9HQVi2tpLju/38jCwA "MATL – Try It Online")
### Explanation
The code keeps increasing a counter *k* = 1, 2, 3, ... For each *k*, solutions *x*, *y* with 1 ≤ *x* ≤ *k*, 1 ≤ *y* ≤ *k* are searched. The process when some solution if found.
This procedure is guaranteed to find only one solution, which is precisely the fundamental one. To see why, note that
1. Any solution *x*>0, *y*>0 for *n*>1 satisfies *x*>*y*.
2. If *x*,*y* is a solution and *x*',*y*' is a different solution then necessarily *x*≠*x*' *and* *y*≠*y*'.
As a consequence of 1 and 2,
* When the procedure stops at a given *k*, only *one* solution exists for that *k*, because if there were two solutions one of them would been found earlier, and the process would have stopped with a smaller *k*.
* This solution is the fundamental one, because, again, if there were a solution with smaller *x* it would have been found earlier.
```
`       % Do...while
  @:U   %   Push row vector [1^2, 2^2, ..., k^2] where k is the iteration index
  t!    %   Duplicate and transpose. Gives the column vector [1^2; 2^2; ...; k^2]
  G*    %   Multiply by input n, element-wise. Gives [n*1^2; n*2^2; ...; n*k^2]
  -     %   Subtract with broadcast. Gives a square matrix of size n
  !     %   Transpose, so that x corresponds to row index and y to column index
  1=&f  %   Push row and column indices of all entries that equal 1. There can
        %   only be (a) zero such entries, in which case the results are [], [],
        %   or (b) one such entry, in which case the results are the solution x, y
  ts~   %   Duplicate, sum, negate. This gives 1 in case (a) or 0 in case (b)
        % End (implicit). Proceed with next iteration if top of the stack is true;
        % that is, if no solution was found.
        % Display (implicit). The stack contains copies of [], and x, y on top.
        % The empty array [] is not displayed
```
[Answer]
# [Python 2](https://docs.python.org/2/), 49 bytes
```
a=input()**.5
x=2
while x%a*x>1:x+=1
print x,x//a
```
[Try it online!](https://tio.run/##JYzBDsIgEAXvfMVKQtJWYoVoDyT4L2ipJWm3hGBcvx6pHt9k5sVPnjfUZdoSIASE5PDpGyUH1RoGYQLsutNVqIM9112N@Mp2cet9dAYriClgBi70aLhAWYkn/@CcF2d/ctPuB4ysZu85LB5IuI5uytDRKvbPSVLfu7JXl@EL "Python 2 – Try It Online")
Finds `x` as the smallest number above 1 where `x % sqrt(n) <= 1/x`. Then, finds `y` from `x` as `y = floor(x / sqrt(n))`.
[Answer]
# [Haskell](https://www.haskell.org/), 46 bytes
A straightforward brute force search. This makes use of the fact that a fundamental solution \$(x,y)\$ satisfying \$x^2 - ny^2 = 1 \$ must have \$y \leq x\$.
```
f n=[(x,y)|x<-[1..],y<-[1..x],x^2-n*y^2==1]!!0
```
[Try it online!](https://tio.run/##Jca9DkAwFAbQV7kSA/JV3IqfQb1IU4mBEDSCoU28ew3OdJbx3qZ9D2Emq3Ti4NPXdUJznhv4P87ADVLYzA9SKTZRVIRjXC0pOq/VPhTTTF3ck5YoUaFGgxZcgBkswaUJHw "Haskell – Try It Online")
[Answer]
# C# (Visual C# Interactive Compiler), ~~70~~ 69 bytes
```
n=>{int x=1;var y=.1;for(;y%1>0;)y=Math.Sqrt(-x*~++x/n);return(x,y);}
```
Port of [my Java 8 answer](https://codegolf.stackexchange.com/a/183305/52210), but outputs a tuple instead of a string to save bytes.
[Try it online.](https://tio.run/##RYzBCoJAFEX3fsVLEGYaNQ3a9ByXrWrVok0bs5EexEjjGCNRvz4pBq0OXO45dZfUHfldr@vi2vaXu4rZjzN4CQ1Ir2X5Im3ByRyflYFBpjk2rWE4RHmZIR/kobK39PgwliVu@RHCrTRHo2xvNHPxwPHtMZiUOQwk1whUyE02QggeAFDD/hXiUb6Q2bQDnAxZtSetGIlwe7ahaMYDR/8F)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes
```
‘ɼ²×³‘½µ⁺%1$¿;®
```
[Try it online!](https://tio.run/##ASkA1v9qZWxsef//4oCYybzCssOXwrPigJjCvcK14oG6JTEkwr87wq7///8yOQ "Jelly – Try It Online")
A full program that takes a single argument `n` and returns a tuple of `x, y`. 
[Answer]
# [Husk](https://github.com/barbuz/Husk), 12 bytes
```
ḟΛ¤ȯ=→*⁰□π2N
```
[Try it online!](https://tio.run/##ASIA3f9odXNr///huJ/Om8KkyK894oaSKuKBsOKWoc@AMk7///81 "Husk – Try It Online")
## Explanation
```
ḟΛ¤ȯ=→*⁰□π2N  Input is n, accessed through ⁰.
           N  Natural numbers: [1,2,3,4,..
         π2   2-tuples, ordered by sum: [[1,1],[1,2],[2,1],[1,3],[2,2],..
ḟ             Find the first that satisfies this:
 Λ             All adjacent pairs x,y satisfy this:
  ¤     □       Square both: x²,y²
   ȯ  *⁰        Multiply second number by n: x²,ny²
     →          Increment second number: x²,ny²+1
    =           These are equal.
```
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf), 12 bytes
```
ökî²*)_°▼Þ√î
```
[Try it online!](https://tio.run/##ASgA1/9tYXRoZ29sZv//w7Zrw67CsiopX8Kw4pa8w57iiJrDrv//MTAKMjL/ "MathGolf – Try It Online")
I'm throwing a Hail Mary when it comes to the output formatting. If it's not allowed, I have a solution which is 1 byte longer. The output format is `x.0y`, where `.0` is the separator between the two numbers. 
## Explanation
```
ö       ▼      do-while-true with popping
 k             read integer from input
  î²           index of current loop (1-based) squared
    *          multiply the two
     )         increment (gives the potential x candidate
      _        duplicate TOS
       °       is perfect square
         Þ     discard everything but TOS
          √    square root
           î   index of previous loop (1-based)
```
I took some inspiration from Emigna's 05AB1E answer, but was able to find some improvements. If the separator I chose is not allowed, add a space before the last byte for a byte count of 13. 
[Answer]
# APL(NARS), 906 bytes
```
r←sqrti w;i;c;m
m←⎕ct⋄⎕ct←0⋄r←1⋄→3×⍳w≤3⋄r←2⋄→3×⍳w≤8⋄r←w÷2⋄c←0
i←⌊(2×r)÷⍨w+r×r⋄→3×⍳1≠×r-i⋄r←i⋄c+←1⋄→2×⍳c<900⋄r←⍬
⎕ct←m
r←pell w;a0;a;p;q2;p2;t;q;P;P1;Q;c;m
   r←⍬⋄→0×⍳w≤0⋄a0←a←sqrti w⋄→0×⍳a≡⍬⋄m←⎕ct⋄⎕ct←0⋄Q←p←1⋄c←P←P1←q2←p2←0⋄q←÷a
L: t←p2+a×p⋄p2←p⋄p←t
   t←q2+a×q
   :if c≠0⋄q2←q⋄:endif
   q←t           
   P←(a×Q)-P
   →Z×⍳Q=0⋄Q←Q÷⍨w-P×P
   →Z×⍳Q=0⋄a←⌊Q÷⍨a0+P
   c+←1⋄→L×⍳(1≠Q×¯1*c)∧c<10000
   r←p,q
   :if c=10000⋄r←⍬⋄:endif
Z: ⎕ct←m
```
Above there are 2 functions sqrti function that would find the floor square root and pell function would return Zilde for error, and is based reading the page <http://mathworld.wolfram.com/PellEquation.html>
it would use the algo for know the sqrt of a number trhu continue fraction (even if i use one algo for know sqrt using
newton method) and stop when it find p and q such that
```
 p^2-w*q^2=1=((-1)^c)*Qnext
```
Test:
```
  ⎕fmt pell 1x
┌0─┐
│ 0│
└~─┘
  ⎕fmt pell 2x
┌2───┐
│ 3 2│
└~───┘
  ⎕fmt pell 3x
┌2───┐
│ 2 1│
└~───┘
  ⎕fmt pell 5x
┌2───┐
│ 9 4│
└~───┘
  ⎕fmt pell 61x
┌2────────────────────┐
│ 1766319049 226153980│
└~────────────────────┘
  ⎕fmt pell 4x
┌0─┐
│ 0│
└~─┘
  ⎕fmt pell 7373x
┌2───────────────────────────────────────────────────────────┐
│ 146386147086753607603444659849 1704817376311393106805466060│
└~───────────────────────────────────────────────────────────┘
  ⎕fmt pell 1000000000000000000000000000002x
┌2────────────────────────────────────────────────┐
│ 1000000000000000000000000000001 1000000000000000│
└~────────────────────────────────────────────────┘
```
There is a limit for cycles in the loop in sqrti function, and a limit for cycles for the loop in Pell function, both for the possible case number are too much big or algo not converge... (I don't know if sqrti converge every possible input and the same the Pell function too)
[Answer]
# [Groovy](http://groovy-lang.org/), 53 bytes
```
n->x=1;for(y=0.1d;y%1>0;)y=((++x*x-1)/n)**0.5;x+" "+y
```
[Try it online!](https://tio.run/##BcFBCoAgEADAu68QIVAXzT10kvU1YXTRkIhdorfbzDF6f2RWemcLhQlz7cMKpYh7lgVLyk7IWgD2HNCtzXmf4pYZjDYg81PqGme7dbWY3PwB "Groovy – Try It Online")
Port of [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen)'s Java and C# answers
[Answer]
# Pyth, 15 bytes
```
fsIJ@ct*TTQ2 2J
```
Try it online [here](https://pyth.herokuapp.com/?code=fsIJ%40ct%2ATTQ2%202J&input=31&debug=0). Output is `x` then `y` separated by a newline.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 41 bytes
```
{1//.y_/;!NumberQ[x=√(y^2#+1)]:>y+1,x}&
```
`√` is the 3-byte Unicode character #221A. Outputs the solution in the order (y,x) instead of (x,y). As usual with the imperfect `//.` and its limited iterations, only works on inputs where the true value of `y` is at most 65538.
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n277v9pQX1@vMl7fWtGvNDcptSgwusL2Uccsjco4I2VtQ81YK7tKbUOdilq1/wFFmXklCg7p0YaWsf//AwA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 45 bytes
```
11v
+$\~:1
:}/!?:-1v?=1-*}:{*:@:{*:
$  naon;>
```
[Try it online!](https://tio.run/##S8sszvj/39CwjEtbJabOypDLqlZf0d5K17DM3tZQV6vWqlrLygFEcKkoKOQl5udZ2/3//1@3TMEUAA "><> – Try It Online")
Brute force algorithm, searching from `x=2` upwards, with `y=x-1` and decrementing on each loop, incrementing `x` when `y` reaches 0. Output is `x` followed by `y`, separated by a newline.
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 69 bytes
```
n=>{for(int x=2,y;;x++)for(y=0;y<=x;y++)if(x*x-y*y*n==1)return(x,y);}
```
[Try it online!](https://tio.run/##NYwxC8IwEIX3/opYEJKmlbbg4vU6Ounk4OIipaG3RExTyCH@9pgKfXD34Lt7b5irYaZ4XuzQkfWlXFca1RuMFvuPebmViYBtyQBBa7Uixhq4wwCcABkZilBxwYVFbJQb/eKsDCUr@EbItg7CFgR1eKyTpVwm/krx69NPh9vbeUlq3@yw3m5C3B358UJ2lKTz08Pn2qQnBfEH "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 75 bytes
```
lambda i:next((x,y)for x in range(2,i**i)for y in range(x)if~-x**2==i*y**2)
```
[Try it online!](https://tio.run/##RczBasMwEEXRX9FSErfgmZFjO@AvabpQadwKWicYL@RNf91xuunqweHy7tv6dZttn8bL/p1/3j@yK@f5WlfvK1uYbourrsxuyfPn1SslxvKn27/WUKbflxqjjmOJ27Fhfyb5mbwqRsuJjh5pEEEUMSQhLdIhhw9ogwqqqKEJPaEd2qMD1mCCHUeGJazFOqzHBlJDEpKSjJRI7dvZ3Zcyrz7jJp9D2B8 "Python 3 – Try It Online")
# Explanation
Brute force. Using $$x<i^i$$ as an upper search bound, which is well below [the definite upper limit of the fundamental solution to Pell's equation](https://math.stackexchange.com/questions/1904192/bounding-fundamental-solution-of-the-pell-equation) $$x\leq i!$$
This code would also run in Python 2. However, the range() function in Python 2 creates a list instead of a generator like in Python 3 and is thus immensely inefficient.
---
With inifinte time and memory, one could use a list comprehension instead of the iterator and save 3 bytes like so:
# [Python 3](https://docs.python.org/3/), 72 bytes
```
lambda i:[(x,y)for x in range(i**i)for y in range(x)if~-x**2==i*y**2][1]
```
[Try it online!](https://tio.run/##RczNaoNAGIXhW5mlDm/B78eoAa/EupiQ2g60JkgWusmtW9NNVwceXs59e3zdZtun/n3/Tj@Xawr5PBQrWzndlrCGPIclzZ8fRY4x/9n2b2uZp@fbGqP2fY7bseMg4/6q0qsaFKPmREOLVIggihjiSI00yOEdWqGCKmqooye0QVu0wypMsOPIMMdqrMFarMMrXHDFDXe8Hs/hvuT5USTCVKSy3H8B "Python 3 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 64 bytes
```
f=lambda n,x=2,y=1:x*x-n*y*y-1and f(n,x+(x==y),y*(y<x)+1)or(x,y)
```
[Try it online!](https://tio.run/##DcrBCoAgDADQX/G4mR6MDhHtYwyRgloiBtvXm@f3irbz5bn3THd8jhQNO6HZKYVNrHi2atWHyMlkGDSBECk6taC74BTwrSBOsZd6cRvp4vI1QOzL@gM "Python 2 – Try It Online")
Returns `(x, y)`.
]