LeetCode 201. Bitwise AND of Numbers Range in F#

URL

Bitwise AND of Numbers Range - LeetCode

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/challenge/202402/bitwise_and_of_numbers_range/main.fsx

let rangeBitwiseAnd (left: int) (right: int) : int =
    let rec rangeBitwiseAnd' left right shifts =
        if left = right then
            left <<< shifts
        else
            rangeBitwiseAnd' (left >>> 1) (right >>> 1) (shifts + 1)

    rangeBitwiseAnd' left right 0