# Untitled

unknown

c_cpp

2 years ago

530 B

1

Indexable

Never

^{}

#include <stdio.h> #define LIM 4000000 int main() { /* a = 1, b = 2, c = 3. -> a = 2, b = 3, c = 5. -> a = 3, b = 5, c = 8. Basically we move forward with a single element each time, until the limit is reached, and simply check if b (starting from the first even number) is even. */ int a = 1, b = 2, c = 0, sum = 0, temp; while (b < LIM) { if (b % 2 == 0) sum += b; c = a + b; a = b; b = c; } printf("%d", sum); return 0; }