recrusion and iterate the function using python

technical talkiess
0

 def recrusion_iterate(n):

    fac = 1

    for i in range(n):

        fac = fac * (i+1)

    return fac

        

def function_recrsion(n):

    if(n==1):

        return 1

    else:

        return n * function_recrsion(n-1)


def fibonacci_number(n):

    f_number = 0

    if(n == 1):

        return 0

    elif(n == 2):

        return 1

    else:

        return fibonacci_number(n-1) + fibonacci_number(n-2)

        

number = int(input("Enter the number"))

print(recrusion_iterate(number))

print(function_recrsion(number))

print(fibonacci_number(number))

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)