modularized code for 9 as 'Pythagorean'. finished general answer for 9