Reputation: 1
I was wondering how to find the GCD of two inputs on super simple CPU I have been struggling because there is only 16 bits of memory, so I am not sure how to edit the GCD program to accept two inputs without going beyond the memory capabilities? Could someone help please thank you!
Upvotes: 0
Views: 131
Reputation: 608
You could use the euclidean gcd algorithm. If both inputs fit in 16 bits it will work for you This is the pseudocode:
function gcd(a, b)
while b ≠ 0
t := b;
b := a mod b;
a := t;
return a;
Upvotes: 1