The Fibonacci Sequence is the following infinite sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …. The first element is 0, the second is 1 and the following will be the sum of the two previous numbers.

Write a function in Python that receives the desired position and returns the Fibonacci number pertinent to that position. For instance, if the user calls the function and inputs 7, the output should be 8. Show desk checks for 1, 2, and 12.

Write a function that receives any number and returns the Fibonacci number closest to that number. For instance, if the user calls the function and inputs 30, the output should be 34. Show desk checks with 27, 27.5 and 28.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import numpy as np
import pdb

def fibanocci_compute(num, CntFlag):
    if CntFlag == 1:
       cntr =2
       fSeries = np.array([0, 1])
       while cntr <= num:
            fSeries = np.append(fSeries, fSeries[-1]+fSeries[-2])
            cntr = cntr + 1
       return fSeries[-2]
       fSeries = np.array([0, 1])
       while fSeries[-1] <= num:
            fSeries = np.append(fSeries, fSeries[-1]+fSeries[-2])
       if (num - fSeries[-2]) <= (fSeries[-1] - num):
            return fSeries[-2]
            return fSeries[-1]...

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats