A video settings panel shows each resolution with its aspect ratio, such as 1920 × 1080 with the label 16:9.
Write aspectRatioLabel(width, height) that returns the ratio in lowest terms as a string "w:h": divide both numbers by their greatest common divisor.
Input: width = 1920, height = 1080 Output: "16:9"
The greatest common divisor is 120: 1920 / 120 = 16 and 1080 / 120 = 9.
Input: width = 1080, height = 1080 Output: "1:1"
A square screen: both sides divide by 1080.
1 <= width, height <= 10^12Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #634 Aspect Ratio Label. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.