DongPad

如题,1+1+2+3+5+8+13+…?

let sumfib n =
    let rec fib x =
        match x with
        | 1 -> 1
        | 2 -> 1
        | x -> fib(x-2)+fib(x-1)   
    let rec addfib x =
        match x with
        | 1 -> 1
        | x -> fib (x)+ addfib (x-1)   
    addfib n

cool!

分类:

技术点:

相关文章: