You are viewing a single comment's thread. Return to all comments →
100% python
t = int(input().strip()) for a0 in range(t): n = int(input().strip()) sum_of_sq = n * (n + 1) * (2 * n + 1) / 6 sq_of_sum = (n * (1 + n) / 2) ** 2 print(int(abs(sum_of_sq - sq_of_sum)))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #6: Sum square difference
You are viewing a single comment's thread. Return to all comments →
100% python