Last active
October 12, 2022 03:43
-
-
Save kobaatsu/3aa1aa9b39b2fcd6d2de698decef56d6 to your computer and use it in GitHub Desktop.
ユークリッド互除法 #js
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
// https://blog.ver001.com/javascript-aspect-ratio/ | |
const getGCD = (a, b) => (b === 0 ? a : getGCD(b, a % b)); | |
const getAspectRatio = (w, h) => { | |
const gcd = getGCD(w, h); | |
return `${w / gcd}:${h / gcd}`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment