Write a program that takes a value x and then outputs x Fibonnaci numbers. E.g. if x=6 output would be 1 1 2 3 5 8

First define a method that takes a value n and prints the nth number in the Fibonacci sequence. E.g. if n=3....fib(n)=2. ## Here this is done by recursion (a method that calls itself).def fib(n):  if n<=1:    return 1  else:    return fib(n-2) + fib(n-1)## Then define a method to call fib on every number up to the given value x (e.g. fib(0) fib(1) fib(2)) and print the result each timedef fibStarter(x):  for i in range(x):    print(fib(i)) ## Finally call this method to see it working fibStarter(20)

PB

Related Python Mentoring answers

All answers ▸

Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".


How would you write a while loop to print all even numbers from 1-10?


Explain how you would write a python program that takes a rectangle and a point in a 2D space as command-line arguments and checks if they intersect.


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs