For lcm try this one:

int lcm(int a,int b)

{

int n;

if(a<b)

{

n=a;

a=b;

b=n;

}

for(n=a;n%b!=0;n+=a)

return n;

}

int lcm(int a,int b)

{

int n;

if(a<b)

{

n=a;

a=b;

b=n;

}

for(n=a;n%b!=0;n+=a)

return n;

}

int lcm(int a,int b)

{

int n;

if(a<b)

{

n=a;

a=b;

b=n;

}

for(n=a;n%b!=0;n+=a)

return n;

}

After 8 posts I would have thought you would know about code blocks by now. USE THEM PLEASE.

Code:

int lcm(int a;int b) { int n; if(a<b) { n=a; a=b; b=n; } for(n=a;n%b!=0;n+=a) return n; }

i had written that function using blocks.i don't know what happened when i posted it.

Added that for you now.

thank you.

Thanks, and in return I'll give you my code which might help someone.

Code:

int gcd( int x, int y) { if ( y == 0 ) { return x; } else if (x%y == 0) { return y; } else { return gcd(y,x%y); } }

Code:

void gcd(int x, int y) { if (x > y) { int c; while(1) { c = x % y; return y; x = y; y = c; } if (y > x) { int d; while(1) { d = x % y; return x; y = x; x = d; } } }

Quote:

Originally Posted byCOKEDUDE

Code:void gcd(int x, int y) { if (x > y) { int c; while(1) { c = x % y; return y; x = y; y = c; } if (y > x) { int d; while(1) { d = x % y; return x; y = x; x = d; } } }