Hey guys!

I just started out with C and thought the "Euler Project" problems would be a great way to practice.

However, I'm stuck at Problem 5 (What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?). A quick google confirmed that my method was correct but I apparently made a logical error somewhere that gives me 0 as the output always. Any help will be appreciated.

Code:

long lcm(long a, long b);
long greater(long a, long b);
long lesser(long a, long b);
int main(void){
long i;
long m = 1;
for ( i = 1; i <= 20; i++ )
{
m = lcm( m, i);
}
printf("%lf\n", m);
system("PAUSE");
return 0;
}
long lcm(long a, long b)
{
long larger_num;
long smaller_num;
long answer;
long gcd;
larger_num = greater(a, b);
smaller_num = lesser(a, b);
while ( smaller_num != 0 )
{
gcd = larger_num - smaller_num;
larger_num = greater (gcd, smaller_num);
smaller_num = lesser (gcd, smaller_num);
}
answer = a * b / larger_num;
return answer;
}
long greater(long a, long b)
{
if ( a > b)
{
return a;
}
else if ( b > a)
{
return b;
}
else
{
return a;
}
}
long lesser(long a, long b)
{
if ( a < b)
{
return a;
}
else if ( b < a)
{
return b;
}
else
{
return a;
}
}