Ian Dorian Macleod
Problem 1
Problem Statement
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
url: https://projecteuler.net/problem=1
Approach
In order to check that a number is divisible by 3 or 5, we will use the modulo operator. For example, $x \mod y := r(x / y)$ where the operation $r()$ denotes the remainder of division. Since the modulo operator will tell us whether or not any value $i < 1000$ is divisible by three or five (any number is evenly divisible by another number if the remainder is zero), we can now easily code up the solution to this problem.
C++ implementation

#include <stdc++.h> 
using namespace std;

int sumDivisible(int n) {
    int sum = 0;
    for(int i = 1; i < n; i++) {
        if (i % 3 == 0 || i % 5 == 0) sum += i;
    }
    return sum;
}

int main() {
    cout << sumDivisible(1000) << endl;
    return 0;
}
        
You can also download the source code for this problem here and compile it on your local machine.
Further Analysis
This problem may seem trivial, but number manipulation with the modulo operator is very useful in a wide variety of different applications across Project Euler. Definitely keep an eye out for it in the future!