Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- fractions = set()
- for den in range(2, n+1):
- for num in range(1, den):
- a, b = num, den
- while a % b > 0:
- a, b = b, a % b
- fractions.add(f'{num//b}/{den//b}')
- res = sorted(list(fractions), key=lambda x: int(x.split('/')[0]) / int(x.split('/')[1]))
- for elem in res:
- print(elem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement