aboutsummaryrefslogtreecommitdiffstats
path: root/05-Smallest-Multiple/smallmult.c
diff options
context:
space:
mode:
Diffstat (limited to '05-Smallest-Multiple/smallmult.c')
-rw-r--r--05-Smallest-Multiple/smallmult.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/05-Smallest-Multiple/smallmult.c b/05-Smallest-Multiple/smallmult.c
new file mode 100644
index 0000000..302f19b
--- /dev/null
+++ b/05-Smallest-Multiple/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);
+}