Skip to content

Instantly share code, notes, and snippets.

@gavinsykes
Created April 29, 2020 21:25
Show Gist options
  • Save gavinsykes/bcf759e65bc34e0fc0c442a302898078 to your computer and use it in GitHub Desktop.
Save gavinsykes/bcf759e65bc34e0fc0c442a302898078 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int euler_1(int n);
int main() {
int n;
scanf("Please enter a number here: %d",&n);
printf("Here is your answer: %d\n",euler_1(n));
return 0;
}
int euler_1(int n) {
int result = 0;
float x = n/3;
float y = n/5;
for(int i = 1; i < x; i++) {
result += 3*i;
}
for (int i = 1; i < y; i++) {
if (5*i % 3 != 0) {
result += 5*i;
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment