Last active
September 11, 2020 21:12
-
-
Save betaprojects/7d6636eead2e14cc692877d0ae2ba8ea to your computer and use it in GitHub Desktop.
Project Euler & HackerRank problem 6 solution: Compare the sum of squares and sum squared - solved using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
n = int(input('first n natural numbers, n =')) | |
print ("Difference: (Σn)² - Σn² =", n*(n-1)*(n+1)*(3*n+2)//12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment