aboutsummaryrefslogtreecommitdiffstats
path: root/05-Smallest-Multiple/smallmult.c
blob: 302f19b48787078501faa30b34e8c1813f3e60d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
}