#include <stdio.h>

/* This is a program to solve problem 5 of the PE problems. This should generate the

smallest number that is divisible by all integers 1-20

*/

main ( void )

{

printf ( "Smallest # evenly divisible by 1-20: " ) ;

//Init counter

int j = 21 ;

//init the answer variable

int answer ;

//Loop that runs until we quit it

while ( j > 20 ) {

//Loop that checks the number J for divisibility

for ( int i = 20 ; i > 0 ; i -- ) {

if ( j % i != 0 ) { //If its not evenly divisible, increment and quit

j ++;

break ;

}

if ( i == 1 ) { //If it makes it all the way to 1, its the answer

answer = j ; //store answer

printf ( "%d" , answer ) ;

j = 0 ; //to exit loop //to exit while loop

break ; //to exit for loop

}

}

}

getchar ( ) ;