hey how's it today we're making the Fibonacci function using python we're going to implement the function using an alterative approach and a recursive Approach at the end we'll refine our recursive approach using memorization let's begin for our iterative version we start by defining our function we're taking in parameter n for which our function will return the N Fibonacci number so if we input five then we should get three which is the fifth Fibonacci number let's store our initial values 0 and one in the variable A and B we know that if our function takes in one we need to return zero and if we take in two we need to return one so let's create a condition now if n is equal to 1 we return zero and since we have one for the second and third number we can just return one so if n = to 2 or n = to 3 then we just return one now for every other n so for I in range n we set a new variable C and assign it the value a plus b we shift a and assign it a new value B after that we assign C to B and return C let's use a for Loop to call our Fibonacci function and generate the first 10 numbers now for our recursive approach we need to call our recursive function with arguments nus1 and nus 2 within our function Fun Since Fibonacci n is equal to Fibonacci nus1 plus Fibonacci nus 2 we'll now store the result and finally return the result lastly let's refine our recursive function because it's still not very efficient especially for larger numbers of n the method we use is called memorization because it saves Time by remembering and reusing results from previous calculations so it doesn't have to repeat them well start by adding a default empty dictionary parameter to our function after that we'll check if we already calculated the number and return its value if true now let's modify our code and store our return values in result and add another condition so else if n is bigger than three then we store the recursive calculations in result then finally we just store the result in our dictionary and return the result so now our recursive function works better for larger values of n as well there's many ways to implement the Fibonacci function in Python leave a like if this helps and I'll see you next time