Skip to content

Instantly share code, notes, and snippets.

@matinkaboli
Created September 21, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matinkaboli/b1a826c303f2174220762ec5a7235b39 to your computer and use it in GitHub Desktop.
Save matinkaboli/b1a826c303f2174220762ec5a7235b39 to your computer and use it in GitHub Desktop.
#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