\(\displaystyle{\left({1}+\sqrt{{2}}\right)}^{{n}}={a}_{{n}}+{b}_{{n}}\sqrt{{2}}\)

for some integers \(\displaystyle{a}_{{n}},{b}_{{n}}.\)

But, the same binomial formula shows you that (convince yourself of this)

\(\displaystyle{\left({1}-\sqrt{{2}}\right)}^{{n}}={a}_{{n}}-{b}_{{n}}\sqrt{{2}}\)

for the same integers \(\displaystyle{a}_{{n}},{b}_{{n}}.\)

Then comes the hint: Calculate both

\(\displaystyle{\left({a}_{{n}}+{b}_{{n}}\sqrt{{2}}\right)}{\left({a}_{{n}}-{b}_{{n}}\sqrt{{2}}\right)}\)

and

\(\displaystyle{\left({1}+\sqrt{{2}}\right)}^{{n}}{\left({1}-\sqrt{{2}}\right)}^{{n}}={\left[{\left({1}+\sqrt{{2}}\right)}{\left({1}-\sqrt{{2}}\right)}\right]}^{{n}}\)

and compare.

You will get that \(\displaystyle{a}{\frac{{{2}}}{{{n}}}}-{2}{b}{\frac{{{2}}}{{{n}}}}={\left(-{1}\right)}^{{n}}\), so \(\displaystyle{a}{\frac{{{2}}}{{{n}}}}\) and \(\displaystyle{2}{b}{\frac{{{2}}}{{{n}}}}\) differ from each other by one, and \(\displaystyle{p}\) will be the larger of the two.