Skip to content

Instantly share code, notes, and snippets.

@matinkaboli
Created September 21, 2017 21:34
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/122ea2d4a8236be1acf302a7c901df2f to your computer and use it in GitHub Desktop.
Save matinkaboli/122ea2d4a8236be1acf302a7c901df2f to your computer and use it in GitHub Desktop.
#include <stdio.h>
int checkNumbers(int n) {
if (n % 3 == 0 || n % 5 == 0) {
return 1;
}
return 0;
}
int main() {
long sum = 0;
for (int i = 0; i < 1000000; i++) {
if (checkNumbers(i)) sum += i;
}
printf("%ld\n", sum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment