From c1a037eaa8198935dd4bf5f20e8df398f5f0d910 Mon Sep 17 00:00:00 2001 From: mjfernez Date: Tue, 4 Feb 2020 20:17:47 -0500 Subject: more cleanup, more c examples --- smallmult.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 smallmult.c (limited to 'smallmult.c') 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 +#include + +// 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); +} -- cgit v1.2.3