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
Which kind of a person will you be if you prove to be accountable for your actions?
Black_prince [1.1K]

Answer: You would be a person of integrity.

Explanation: Look up Integrity for details.

3 0
3 years ago
How do u answer questions on brainly if ur on the app and on a phone. For me there is no answer button :(
Rudik [331]

Answer:

oh for me there is maybe try reloading?

Explanation:

8 0
2 years ago
What is the full form of com​
nignag [31]

The answer is:

Commercial

3 0
3 years ago
When Windows deletes the driver package and driver files, in what situation might it not delete driver files used by the device
musickatia [10]

Answer:

when there is no junk

Explanation:

3 0
3 years ago
HTML coding tells a computer what to do by using a series of?
kkurt [141]

Answer:

Elements

Explanation:

A computer code acts as a medium by which a person can communicate with the computer machine.

One such language is known as HTML or hypertext markup language.  HTML stands for Hypertext markup language which is used to markup the language for web pages in computer.

The HTML series consists of a series of elements which are enclosed in the tags commonly called start tag and a stop tag.

Example <head>  

here,  

the head is a series of elements.

< start-tag

> stop-tag

Thus, element is the correct answer.

5 0
3 years ago
Other questions:
  • What happens to formulas with relative cell references when they are copied using the fill handle?
    12·1 answer
  • Write a Java application that inputs a series of 10 integers and determines and prints the largest and smallest integer. Use a c
    12·1 answer
  • What is the financial aspect for a business as to what database software they will buy?
    6·1 answer
  • Quiz
    6·2 answers
  • What is ana absolute adress
    11·1 answer
  • Modify class Time2 of fig 8.5, (which is split into four pictures) to include a tick method that increments the time stored in a
    8·1 answer
  • Assume variables SimpleWriter out and int n are already declared in each case. Write a while loop that printsA. All squares less
    11·1 answer
  • What model involves the creation of data and process models during the development of an application
    14·1 answer
  • What would a system unit that is integrated with the display and keyboard would be considered?
    6·1 answer
  • CSNET Stand for in a computer
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!