Dcoder icon

Archie and his Homework @ Dcoder

By Lochard | As a newbie programmer | 11 Apr 2023


Problem: Archie was given a homework by his teacher. He is given a fraction and he needs to write it in its reduced form. Archie is not good at Maths. Help Archie finish his homework.

Input: 2 integers separated by space denoting the numerator and denominator respectively.

Output: Print the reduced form of the fraction

Constraints: 1 ≤ N ≤ D ≤ 1000

Sample Input: 20 40

Sample Output: 

1 2

from math import gcd
x, y = map(int, input().split())
d = gcd(x, y)
print(x//d, y//d)

How do you rate this article?

0


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.