Created
September 21, 2017 21:40
-
-
Save matinkaboli/b1a826c303f2174220762ec5a7235b39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int is_even(int n) { | |
if (n % 2 == 0) { | |
return 1; | |
} | |
return 0; | |
} | |
int main() { | |
int fs = 1; | |
int sc = 2; | |
long sum = 0; | |
while(fs < 4000000) { | |
if (is_even(fs)) { sum += fs; } | |
int new_number = fs + sc; | |
fs = sc; | |
sc = new_number; | |
} | |
printf("%ld\n", sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment