The greatest number of sides the polygon could have is $360$.

As each interior angle of the polygon is a whole number of degrees, the same must apply to each exterior angle. The sum of the exterior angles of a polygon is $360^{\circ}$ and so the greatest number of sides will be that of $360$-sided polygon in which each interior angle is $179^{\circ}$, thus making each exterior angle $1^{\circ}$.

As each interior angle of the polygon is a whole number of degrees, the same must apply to each exterior angle. The sum of the exterior angles of a polygon is $360^{\circ}$ and so the greatest number of sides will be that of $360$-sided polygon in which each interior angle is $179^{\circ}$, thus making each exterior angle $1^{\circ}$.

*This problem is taken from the UKMT Mathematical Challenges.*