Created
August 26, 2024 20:21
-
-
Save adamelliotfields/54be9c954206ed7c1d46aeec4c0aad44 to your computer and use it in GitHub Desktop.
Python Aspect Ratio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def aspect_ratio(width=0, height=0): | |
if width <= 0 or height <= 0: | |
return None | |
a, b = width, height | |
while b: | |
a, b = b, a % b | |
gcd = a | |
return (width // gcd, height // gcd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment