p=0 for x in range(1,50+1): if x**2 % 3 == 0 : p=p+x**2 print (p)