Generating Fibonacci series in F#

后端 未结 11 1975
南方客
南方客 2020-12-31 02:58

I\'m just starting to learn F# using VS2010 and below is my first attempt at generating the Fibonacci series. What I\'m trying to do is to build a list of all numbers less

11条回答
  •  萌比男神i
    2020-12-31 03:43

    Here's a good article by .Net guru Scott Hanselman on generating fibonacci series in F#

    let rec fib n = if n < 2 then 1 else fib (n-2) + fib(n-1)
    

    http://www.hanselman.com/blog/TheWeeklySourceCode13FibonacciEdition.aspx

    It also compares with other languages as a reference

提交回复
热议问题