Finding GCF in java
Hi, I'm doing a project with Java, and I need to find the GCF of a fraction. I really don't know how to do this, and would like a code to basically reduce the fraction. Like 12 over 6. The GCF is 6, and the fraction is reduced to 2 over 1.
I am using J builder, not sure if it would make a difference
Start with the number that is the smallest (numerator or denominator) and then count down trying each one to see if they can divide evenly into both. The way to tell is to use the mod operator '%' and see if the answer is zero.