LeetCode 70. Climbing Stairs in F#

URL

https://leetcode.com/problems/climbing-stairs/description/?envType=daily-question&envId=2024-01-18

Code

https://github.com/syohex/dotnet-study/blob/master/fsharp/leetcode/challenge/202401/climbing_stairs/main.fsx

let climbStairs (n: int) : int =
    let rec climbStairs' i n prev1 prev2 =
        if i >= n then
            prev1 + prev2
        else
            climbStairs' (i + 1) n (prev1 + prev2) prev1

    match n with
    | 1 -> 1
    | _ -> climbStairs' 2 n 1 1