LeetCode 191. Number of 1 Bits in F#

URL

leetcode.com/problems/number-of-1-bits

Code

github.com/syohex/dotnet-study/blob/master/..

let hammingWeight (n: uint32) : int =
    let rec hammingWeight' (n: uint32) acc =
        if n = 0u then
            acc
        else
            let acc' = if n &&& 1u = 1u then acc + 1 else acc
            hammingWeight' (n >>> 1) acc'

    hammingWeight' n 0