Skip to content

Instantly share code, notes, and snippets.

@oldhill
Created March 6, 2016 23:53
Show Gist options
  • Save oldhill/500c759d35120d3023ac to your computer and use it in GitHub Desktop.
Save oldhill/500c759d35120d3023ac to your computer and use it in GitHub Desktop.
euler in c
#include <stdio.h>
int main()
{
int n = 100000000;
printf("\nFinding sum of multiples of 3 and 5 below %d\n", n);
long total = 0;
for (int i = 0; i < n; ++i) {
if (i % 3 == 0) {
total = total + i;
}
else if (i % 5 == 0) {
total = total + i;
}
}
printf("Result: %ld\n", total);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment