1. Help with a program

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 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;
}

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;
}
}```

2. I would bet that %lf is the printf() format for a float - in fact, a double.

Use the right format for a long integer, of course.

3. ahhh feel so dumb now.

Thanks a ton!

Edit: Still gives the wrong answer. Could anyone please point out the mistake I'm making?

4. If you put the print inside the loop, you will see that your program thinks that the LCM of 232,792,560 and 20 is 18,044,195, which is odd. (That is to say: your multiplications overflow, so you should rearrange your calculations to do a division first.)

5. Thank you!

This warrants another question: is there a better IDE than DEV-C++ with regards to debugging?

6. http://www.codeblocks.org/ is the new IDE on top of gcc/mingw (which you're already using).

7. Thank you