Skip to content

Instantly share code, notes, and snippets.

@hjanuschka
Created October 8, 2015 12:13
Show Gist options
  • Save hjanuschka/372a546af73f7900d537 to your computer and use it in GitHub Desktop.
Save hjanuschka/372a546af73f7900d537 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define MY_TRUE 0
#define MY_FALSE -1
#define MAX_NUM 20
int num_is_dividable(int num);
int main(int argc, char ** argv) {
int current=1;
int result=MY_FALSE;
while(num_is_dividable(current) == MY_FALSE) {
current++;
}
printf("DONE: %d\n", current);
}
int num_is_dividable(int num) {
int x;
int is_dividable=MY_TRUE;
for(x = 1; x<=MAX_NUM; x++) {
if(num%x != 0) {
is_dividable=MY_FALSE;
}
}
if(is_dividable == MY_FALSE) {
return MY_FALSE;
} else {
return num;
}
return MY_FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment