I have. I would say ok well since both 6 and 8 are divisible by 2, ill divide the num and dem by 2. Ok its 3/4. But using that method, id have to make it so it would cycle through 2, 3, 4, 5, 6, 7, 8, 9. Isnt there a simpler way?
But using that method, id have to make it so it would cycle through 2, 3, 4, 5, 6, 7, 8, 9. Isnt there a simpler way?
There are certainly other ways to do it, and you can easily find these ways by learning to google. On the other hand, the algorithm you describe is very simple to implement. So, either research another algorithm or get to work on this one. Either way, feel free to ask questions when you have actual code you're trying to write.
use the modulo or how ever you spell that thing lol ( % ) then use a loop maybe something like
1 2 3 4 5 6 7 8 9
unsignedint gcf = 1;
for( unsignedint i = 2; i < HIGHESTNUMBER + 1; i++ ) //highest + 1 in case for
//some reason the highest is the same for both eg 1/1 or 4/4
if( denominator % i == 0 && numerator % i == 0)
gcf = i;