# Euler Problem 1: Multiples of 3 and 5 : C programming solution

**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.

**Solution Approach:**

Being the first problem of the series, its quite a simple one. there are many ways to approach this problem.

Most simplest one is to iterate through all the numbers from 3 to 1000 and check if its divisible by 3 or 5. If they are, just add them to the sum.

**Solution :**

#include "stdio.h" #define LIMIT 1000 int main () { int iter = 3; int sum = 0; while ( iter < LIMIT ) { if( !(iter % 3) || !(iter % 5)) { sum+=iter; } iter++; } printf(" Sum is %d \n",sum); return 0; }

**Answer:** **233168**

Let me know your approach you happen to find a better way to solve this using C programming.

## Leave a Reply