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
The average pH of citrus fruits is 2.2, and this value has been stored in the variable avg_citrus_pH . Provide a statement to di
olasank [31]

Answer:

The statement in Python is:

print("The average pH of citrus fruits is ",avg_citrus_pH)

Java

System.out.print("The average pH of citrus fruits is "+avg_citrus_pH);

C++

cout<<"The average pH of citrus fruits is "<<avg_citrus_pH;

Explanation:

The programming language is not stated; so, I answered the question in 3 languages (Python, Java and C++)

Assume that avg_citrus_pH has been declared and initialized; all you need to do is invoke a print statement and then append the variable

In Python, use print()

In c++, use cout<<

In Java, use System.out.print()

So, the statements are:

Python:

print("The average pH of citrus fruits is ",avg_citrus_pH)

Java

System.out.print("The average pH of citrus fruits is "+avg_citrus_pH);

C++

cout<<"The average pH of citrus fruits is "<<avg_citrus_pH;

8 0
2 years ago
A certain manager makes the following statement "Our internet company is in business for the money, making profits, and making t
julia-pushkina [17]

Answer:

d. Stockholder theory

Explanation:

The theory of maximising profits

8 0
3 years ago
Which of the following refers to a technology with a three-dimensional computer simulation in which a person actively and physic
weqwewe [10]

Answer:

B. Virtual reality

Explanation:

In a virtual reality context, the visual and auditory senses of the user are fed by data (images, sounds) from the computer using a goggle and earphones.  That allows the person to be totally cut off her real physical environment and be totally immersed into the world (reality) managed by the computer.

Not to be confused with<u> augmented reality</u>, where the physical reality and perception of it aren't changed... but an additional layer of information is added on top of it.  Like pointing your phone camera to a building and getting information about the building displayed on your phone.

7 0
3 years ago
Who sings you aint nothing but a broke boi
Ad libitum [116K]

Answer:

Kanye West

The song is Gold Digger

6 0
2 years ago
*/ What's wrong with this program? /* public MyProgram { public static void main(String[] args); } int a, b, c \\ Three integers
gulaghasi [49]

Answer:

A lot is wrong with the program given in the question. See the corrected version below:

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>        int a, b, c;</em>

<em>    //Three integers</em>

<em>    a = 3; b = 4; c = a + b;</em>

<em>        System.out.println("The value of c is " + c);</em>

<em>    }</em>

<em>}</em>

Explanation:

Errors:

1. The main method had a semi colon after it. This is wrong

2. An open brace was supposed to follow the main method

3. The declaration of the variables was supposed to end with a semi colon

4. the correct comment style is // and not \\

5. Initialization of variables was supposed to end with semi colons

6. The output statement had C and not c which is the declared and initialized variable..Java is strictly typed

7. Open and closing braces for the class and method wrongly placed

6 0
3 years ago
Other questions:
  • Which of these is a subdirectory? <br> HTTPS <br> /FAQ <br> .org <br> WWW
    15·1 answer
  • Which of these are examples of metadata for an audio file of a song recording?
    10·2 answers
  • Bushman and bonacci (2004) found that prejudiced participants were ____ likely to return a lost e-mail that had been addressed t
    5·1 answer
  • You have stumbled on an unknown civilization while sailing around the world. The people, who call themselves Zebronians, do math
    11·1 answer
  • If you are worried that team members will not keep sensitive information private, you could ask them to sign a ________ agreemen
    15·1 answer
  • Pls help now the question is very hard someone help me pls​
    6·1 answer
  • In 5-10 sentences, describe the procedure for responding to an e-mail message.
    5·1 answer
  • In addition to developing sketches, computer-aided design programs are used by fashion designers to perform which task?
    10·1 answer
  • True or False? The background color block should be inserted after all the images are added.
    7·1 answer
  • Which window would show you bindings for local area connection 2?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!