Skip to content

Instantly share code, notes, and snippets.

@betaprojects
Last active September 11, 2020 21:12
Show Gist options
  • Save betaprojects/7d6636eead2e14cc692877d0ae2ba8ea to your computer and use it in GitHub Desktop.
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
# -*- 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