You are viewing a single comment's thread. Return to all comments →
import sys
t = int(input().strip()) for a0 in range(t): n = int(input().strip()) s1=0 s2=0 for i in range(1,n+1): s1+=i s2+=i**2 sum=s1**2-s2 print(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 →
!/bin/python3
import sys
t = int(input().strip()) for a0 in range(t): n = int(input().strip()) s1=0 s2=0 for i in range(1,n+1): s1+=i s2+=i**2 sum=s1**2-s2 print(sum)