LeetCode 1688. Count of Matches in Tournament in F#

URL

https://leetcode.com/problems/count-of-matches-in-tournament/description/?envType=daily-question&envId=2023-12-05

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/problems/1688/main.fsx

let numberOfMatches (n: int) : int =
    let rec numberOfMatches' n isEven acc =
        if n <= 1 then
            acc
        else
            let matches = if isEven then n / 2 else (n - 1) / 2
            numberOfMatches' (n - matches) (not isEven) (acc + matches)

    numberOfMatches' n true 0