编辑代码

function solution(width: number, height: number): number {
    let j = 0
    let h = height
    while(width > h && width % h !== 0) {
        h /= 2
    }
    return width / h * (height / h)
}

console.log(solution(1680, 640))

function solution2(width: number, height: number): number {
    if(width % height === 0) return width % height
    return solution2(width, height / 2)
}

console.log(solution(1680, 640))