answersLogoWhite

0

The following code for example is a solution (you could do it with less variables, but this is more readable):
int GCD(int a, int b){
int n, k, c;
n = (a>b)?a:b;
k = (a>b)?b:a;
while (k){
c = n%k;
n=k;
k=c;
}
return n;
}

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran

Add your answer:

Earn +20 pts
Q: Least common multiple in C programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp