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.
This problem is to find that less than 1000 (<1000) is the sum of multiples of 3 and 5.
The first of the Euler's project, getting started, to attract participants. The following is my answer. I prefer simplicity.Algorithm, How to state, how to write:
# Include <stdio. h>
# Include <stdlib. h>
double sumadd ( int N)
{< br> double sum = 0.0;
int I;
for (I = 0; I <1000; I ++)
{< br> If (I % 3 = 0) | (I % 5 = 0)
sum + = I;
}< br> return sum;
}
IntMain (IntArgc,Char* Argv [])
{
DoubleSUM;
Sum = sumadd( 1000 );
Printf("% Lf", Sum );
System("Pause");
Return0;
}
After answering the questions, you can check the replies from other participants. There are really a lot of cool people in it, which are useful for compilation, and there is another language that I don't know.