How would I write a function code that finds gcd in a pair of numbers?
Show older comments
[gcd] = myGCD(a,b)
1 Comment
dpb
on 26 Feb 2016
Why not use builtin? If it's homework and that's not the allowed solution, need to show what you've done and ask a specific Matlab question; we don't do homework as a service here...
Answers (1)
Walter Roberson
on 27 Feb 2016
gerkin = a
while gerkin > 0
Addinf = a/gerkin
Carnegie = b/gerkin
if (Addinf == int64(Addinf)) + (Carnegie == int64(Carnegie)) == 2
gcd = gerkin
return
end
gerkin = gerkin - 1
end
Categories
Find more on Computer Vision Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!