-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheuler1.cpp
More file actions
41 lines (36 loc) · 955 Bytes
/
euler1.cpp
File metadata and controls
41 lines (36 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* =====================================================================================
*
* Filename: euler1.cpp
*
* Description: Implements the first problem of Project Euler and finds
* the sum of the multiples of 3 and 5 below 1000
*
* Version: 1.0
* Created: 03/05/13 21:55:42
* Revision: none
* Compiler: gcc
*
* Author: Robert Halliday (rh), rob_halliday_1@hotmail.com
* Company: rphhpr
*
* =====================================================================================
*/
#include <iostream>
int sum_multiples(int multiple, int max_num)
{
int start = multiple;
int total = 0;
while(start < max_num)
{
total += start;
start += multiple;
}
return total;
}
int main()
{
int result = sum_multiples(3, 1000) + sum_multiples(5, 1000);
std::cout << "sum is: " << result << std::endl;
return 0;
}