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;

}

0

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;

}

0

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

0

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

0

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

0

Added that for you now.

0

thank you.

0

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

0

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

0

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

0