Simplify Fraction
Computer Mathematics
Medium
3 views
Problem Description
Given a/b, reduce it to lowest terms and keep sign in numerator.
Input Format
Two integers a b (b!=0).
Output Format
Two integers p q.
Official Solution
Let sign = sign(a)*sign(b). Work with abs values. g=gcd(abs(a),abs(b)). p=sign*abs(a)/g, q=abs(b)/g.
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!