Project Euler problem:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9
10
3 or 5
3, 5, 6 and 9
Direct translation of your python code:
#include int main(int argc, char *argv[]) { int sum = 0; for (int x = 0; x < 1000; x++) { if (x % 5 == 0 || x % 3 == 0) sum += x; } printf("%d", sum); }