Draw the octagon with a triangle stuck to one of the sides.
The sum of all the angles in a polygon with x sides is (x -2)(180o)
The interior angles of the octagon are (8 - 2)(180o) = 1080o
So one angle of the octagon is 1080o/8 = 135o
Add that to the 60o of the triangle angle touching the octagon angle
and you get a total of 195o which makes the angle on the other side
which is an interior angle of our n-gon be 360o - 195o = 165o
I'm going to drop the degrees sign for convenience
Since n is the number of sides of our n-gon,
and there are the same number of angles as there are sides,
the total of the interior angles of our n-gon is (165)(n)
But the total is also (n - 2)(180) so set them equal
165n = 180n - 360
165n -180n = -360
multiply both sides by -1
180n -165n = 360
15n = 360
n = 24