LeetCode 1688. Count of Matches in Tournament in F#
URL
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