Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Decimal = float(input("Enter decimal: "))
- minDiff = 0.0001
- q = 1
- while True:
- q += 1
- p = round(q * Decimal)
- if abs((p / q) - Decimal) <= minDiff:
- print(f"{p}/{q}")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement