diagonals = 1 step = 2 current = 1 while step<1001: for i in range(1,5): current +=step diagonals += current step += 2 print diagonals
669171001