Created
April 29, 2020 21:25
-
-
Save gavinsykes/bcf759e65bc34e0fc0c442a302898078 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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