a: \(P=\left(\dfrac{\left(\sqrt{a}-1\right)\left(a+\sqrt{a}+1\right)}{\sqrt{a}\left(\sqrt{a}-1\right)}-\dfrac{\left(\sqrt{a}+1\right)\left(a-\sqrt{a}+1\right)}{\sqrt{a}\left(\sqrt{a}+1\right)}\right)\cdot\dfrac{a-2}{a+2}\)
\(=\left(\dfrac{a+\sqrt{a}+1-a+\sqrt{a}-1}{\sqrt{a}}\right)\cdot\dfrac{a-2}{a+2}\)
\(=\dfrac{2\sqrt{a}}{\sqrt{a}}\cdot\dfrac{a-2}{a+2}=\dfrac{2a-4}{a+2}\)
b: Để P là số nguyên thì \(2a+4-8⋮a+2\)
\(\Leftrightarrow a+2\in\left\{1;-1;2;-2;4;-4;8;-8\right\}\)
\(\Leftrightarrow a=6\)