aboutsummaryrefslogtreecommitdiffstats
path: root/smallmult.c
diff options
context:
space:
mode:
authormjfernez <mjfernez@gmail.com>2020-02-04 20:17:47 -0500
committermjfernez <mjfernez@gmail.com>2020-02-04 20:17:47 -0500
commitc1a037eaa8198935dd4bf5f20e8df398f5f0d910 (patch)
treef73a20777f817e654d57178017c55eb627a60731 /smallmult.c
parent6e19bf3ce11c8722e3260c0457f0389193fd9251 (diff)
downloadProject_Euler_Solutions-c1a037eaa8198935dd4bf5f20e8df398f5f0d910.tar.gz
more cleanup, more c examples
Diffstat (limited to 'smallmult.c')
-rw-r--r--smallmult.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/smallmult.c b/smallmult.c
new file mode 100644
index 0000000..302f19b
--- /dev/null
+++ b/smallmult.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+// num: the number to divide
+// gd: the greatest divisor to count up to
+int isDivisible(int num, int gd){
+ int divisible = 1;
+ for(int i = 1; i < gd; i++){
+ if(num % i != 0)
+ divisible = 0;
+ }
+ return divisible;
+}
+
+int main(){
+ int found = 0;
+ int start = 2520;
+ while(!found){
+ start += 20;
+ found = isDivisible(start, 20);
+ }
+ printf("%d\n", start);
+}