Using synthetic division in both cases,
X^2+16X+65=(X+7)*(_____)+(2)
x+7 | X^2 + 16X + 65
-7 | 1 16 65
| - -7 -63
----------------
1 9 2
Ans: (x+7)(x+9)+2
X^2+10X+27=(X+6)*(_____)+(3)
x+6 | X^2 + 10X + 27
-6 | 1 10 27
| - -6 -24
-----------------
1 4 3
Ans: (x+6)(x+4)+3
Hope this helps,
Prabhat