We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
for t_itr in range(t):
n = int(input().strip())
natural_numbers = sum(list(range(1 , n+1)))
square_natural_number = natural_numbers ** 2
square_number = sum(list(i**2 for i in range(1 , n+1)))
result = difference(square_natural_number, square_number)
List.append(result)
for i in List:
print(i)
Cookie support is required to access HackerRank
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 →
import re import sys
def difference(number1 , number2): return number1 - number2
List = []
if name == 'main': t = int(input().strip())