I used the phythagoras theroem which says if a,b,c are sides of a right angle traingle with c as hypotoneous then
a^2 + b^2 = c^2
in the above example x and x-2 are the sides and x+2 as hypotoneous
of a right angle traingle
so i took x ^2 + (x - 2) ^2 = (x +2)^2
also remember the rule for right angle traingle 3,4,5 and its similar ratio 6 8 10 all of these are right angle traingle with 5 and 10 hypotoneous , so in this question they just twisted it by putting x-2,x,x+2 instead of 6,8 ,10 .
one more commonly used figure is 5,12,13
Hope the above helps.