20 lines
356 B
C
20 lines
356 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
int num = 1;
|
|
int prevnum = 1;
|
|
int sum = 0;
|
|
while (num <= 4000000)
|
|
{
|
|
if (num % 2 == 0)
|
|
sum += num;
|
|
int store = num;
|
|
num = num + prevnum;
|
|
prevnum = store;
|
|
}
|
|
printf("The sum of the even-valued terms of the Fibonacci sequence whose values do not exceed four million is: %d\n", sum);
|
|
}
|