Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Andrew Dahl
/
Project Euler
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
00b91fe9
authored
Nov 15, 2011
by
Andrew Dahl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solved Problem 6
parent
aabc0eca
Hide whitespace changes
Inline
Sidebyside
Showing
2 changed files
with
33 additions
and
0 deletions
6/README
6/main.cpp
6/README
0 → 100644
View file @
00b91fe9
Question:
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 385 = 2640.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
Answer: 25164150
6/main.cpp
0 → 100644
View file @
00b91fe9
#include <iostream>
using
namespace
std
;
int
main
()
{
int
sum_of_squares
=
0
;
int
sum_of_numbers
=
0
;
int
low
=
1
;
int
high
=
100
;
for
(
int
i
=
low
;
i
<=
high
;
i
++
)
{
sum_of_squares
+=
i
*
i
;
sum_of_numbers
+=
i
;
}
cout
<<
(
sum_of_numbers
*
sum_of_numbers
)

sum_of_squares
<<
endl
;
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment