function numberOfMatches(n: number): number {
let remain = n
let matches = 0
while(remain > 1) {
const quot = Math.floor(remain / 2)
matches += quot
const isOdd = (remain & 1) === 1
remain = quot + Number(isOdd)
}
return matches
};