7 kyu

Difference Of Squares

429 of 7,371noku

Description:

Recreation of Project Euler problem #6

Find the difference between the square of the sum of the first n natural numbers (1 <= n <= 100) and the sum of their squares.

Example

For example, when n = 10:

  • The square of the sum of the numbers is:

    (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10)² = 55² = 3025
    
  • The sum of the squares of the numbers is:

    1² + 2² + 3² + 4² + 5² + 6² + 7² + 8² + 9² + 10² = 385
    

Hence the difference between square of the sum of the first ten natural numbers and the sum of the squares of those numbers is: 3025 - 385 = 2640

Fundamentals

More By Author:

Check out these other kata created by noku

Stats:

CreatedJun 28, 2015
PublishedJun 28, 2015
Warriors Trained9626
Total Skips702
Total Code Submissions14489
Total Times Completed7371
Ruby Completions429
JavaScript Completions3193
Python Completions2734
PHP Completions574
C# Completions497
Haskell Completions150
Prolog Completions10
Lua Completions10
C Completions28
Java Completions5
Total Stars43
% of votes with a positive feedback rating94% of 1265
Total "Very Satisfied" Votes1126
Total "Somewhat Satisfied" Votes120
Total "Not Satisfied" Votes19
Total Rank Assessments153
Average Assessed Rank
7 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • noku Avatar
  • ZozoFouchtra Avatar
  • CrazyMerlyn Avatar
  • Jotha Avatar
  • anter69 Avatar
  • myjinxin2015 Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • Voile Avatar
  • Madjosz Avatar
  • Souzooka Avatar
  • rowcased Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • ejini战神 Avatar
  • metatable Avatar
Ad