Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int smallNum;
- int n = getNumerator();
- int d = getDenominator();
- int gcf = 1;
- if (n<d)
- smallNum = n;
- else
- smallNum = d;
- for(int i = smallNum;i>1;i--)
- {
- if( n%i == 0 && d%i==0 )
- gcf = i;
- }
- numerator = n/gcf;
- denominator = d/gcf;
Add Comment
Please, Sign In to add comment