Haskell 斐波那契 数列 递归实现

haskell

let fibonacci n = if n < 3 then 1 else fibonacci (n-2) + fibonacci(n-1)
Prelude> fibonacci 20
6765

python

def factorial(n):

    if n==1 or n==2:
        return 1
    else:
        return factorial(n-1)+factorial(n-2)

#f=factorial(30)
posted @ 2022-08-19 22:57  luoganttcc  阅读(0)  评论(0编辑  收藏  举报