1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
spayn [35]
3 years ago
6

The first and second numbers in the Fibonacci sequence are both 1. After that, each subsequent number is the sum of the two prec

eding numbers. The first several numbers in the sequence are: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, etc. Write a function named fib that takes a positive integer parameter and returns the number at that position of the Fibonacci sequence. For example fib(1)
Computers and Technology
1 answer:
vlabodo [156]3 years ago
7 0

Answer:

In Python:

def fib(nterms):

   n1, n2 = 1, 1

   count = 0

   while count < nterms:

       term = n1

       nth = n1 + n2

       n1 = n2

       n2 = nth

       count += 1

   return term

Explanation:

This line defines the function

def fib(nterms):

This line initializes the first and second terms to 1

   n1, n2 = 1, 1

This line initializes the Fibonacci count to 0

   count = 0

The following while loops gets the number at the position of nterms

<em>   while count < nterms: </em>

<em>        term = n1 </em>

<em>        nth = n1 + n2 </em>

<em>        n1 = n2 </em>

<em>        n2 = nth </em>

<em>        count += 1 </em>

This returns the Fibonnaci term

   return term

You might be interested in
Need help ASAP <br><br> Thankss + BRAINLIST only for correct answers
AVprozaik [17]
Why visit it?
For entertainment, purely for the user to enjoy the content that has been produced for them.

Why was it made?
Netflix is a subscription based service that has been made to allow users to stream TV shows and other entertainment sources. It was made for leisure.
7 0
2 years ago
What is computer ? What is computer program? What is hard disk.
g100num [7]
A computer is a electronic that helps you access the internet/WiFi
4 0
3 years ago
Read 2 more answers
Which of the following is the MOST important consideration when planning your budget?
nata0808 [166]
<span>Budget for fixed expenses before flexible expenses.</span>
5 0
3 years ago
Read 2 more answers
Which of the following is Not included in the Web Accessibility Initiative? Don’t rely on color alone.
Doss [256]
I'm pretty sure it's D. Provide discount software for the underprivileged.
3 0
3 years ago
Need A girl to play wit I'm bored On xbox btw or just to talk too btw be at least 12​
attashe74 [19]

Answer:

im 13 and im a girl wassup

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • The largest group of Linux users is likely to be
    7·1 answer
  • When you pass an array as an argument to a function, the function can modify the contents of the array?
    15·1 answer
  • Jessica finds out that the government introduced a new trade policy that will increase import tariffs. She calls for a meeting o
    15·1 answer
  • Along with an ip address, a subnet mask, and a name server, the other thing required for a computer to operate on a network is a
    15·1 answer
  • PLEASE help me RIGHT NOW!!!!!!!!! I will give a Brainly to anyone who helps me!
    15·1 answer
  • All of the Internet in your country disappears. What happens next?
    13·1 answer
  • Let’s say you’re having trouble locating a file on your computer. Which of the following are good places to look for the file?
    14·1 answer
  • A company is deploying NAFDs in its office to improve employee productivity when dealing with paperwork. Which of the following
    11·1 answer
  • Vices for a research paper
    6·1 answer
  • /*this function represents
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!