Jupiter Please do that Fibonaccin function n is an integer T

Jupiter. Please do that
Fibonacci(n) function. n is an integer. The function returns the nth Fibonacci number. If you do not know what the n-th Fibonacci number is, study it on a Wikipedia page. You must use accumulator variables in your solution. Do not use simultaneous assignment. Write also test0 function to list the first 20 Fibonacci numbers in which numbers are precisely RIGHT JUSTIFIED as illustrate in the following (Blackboard may not show the output precisely. Stick to the RIGHT-JUSTIFIED requirement):

Solution

def fibonacci(n):
first = 0
second = 1
next = 0
for i in range(1,n+1):
if i <= 1:
next = i
else:
next = first + second;
first = second;
second = next;
print \"The \" + str(i).rjust(2) + \"th fibonacci number is: \" + str(next).rjust(5)


def test():
fibonacci(20)

test()

Jupiter. Please do that Fibonacci(n) function. n is an integer. The function returns the nth Fibonacci number. If you do not know what the n-th Fibonacci number

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site