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
faltersainse [42]
3 years ago
15

The Fibonacci numbers are the numbers

Computers and Technology
1 answer:
Doss [256]3 years ago
6 0

Answer:

function fibonacci(n):

  if n is equal to 1 or n is equal to 2:

       return 1

  else:

       return fibonacci(n-1) + fibonacci(n-2)

end of the function

Input the n

Print fibonacci(n)

Explanation:

* The above algorithm (pseudocode) is written considering Python.

Create a function called fibonacci that takes one parameter, n

If n is equal to 1 or 2, return 1 (When n is 1 or 2, the fibonacci numbers are 1)

Otherwise, return the sum of the two previous numbers (When n is not 1 or 2, the fibonacci number is equal to sum of the two previous numbers)

Ask the user for n

Call the function, pass n as a parameter and print the result

You might be interested in
What is the largest decimal value you can represent, using a 86-bit signed<br> integer?
Nataly [62]

Answer:

2^{85}-1

Explanation:

Considering the number are stored using binary notations.

If there are total 86 bits and 1 bit is used as sign bit. Then in total one can have 2^{85} bit combinations since a bit can be either stored as 0 or as 1.

Therefore,  the largest number that can be stored will be 2^{85}-1.

To understand it in better way let's scale down the problem to 3 bits representation. The largest number that can be stored using 3 bits is 111 which in decimal form is 7 and is equal to 2^{3}-1.

4 0
2 years ago
Which function prompts the user to enter information?
Rzqust [24]

Answer:

input() prompts the user to enter information

6 0
3 years ago
Read 2 more answers
What programs are most likely affected by a macro virus?
Iteru [2.4K]

Answer:

Macro viruses usually infect Microsoft Office apps like Word and Excel.

Explanation:

7 0
2 years ago
A ____ is an electronic device, operating under the control of instructions stored in its own memory, that can accept data, proc
taurus [48]

Answer:

Server

Explanation:

- it is an electronic device

- under control of another computer or human

- stored instructions as code

- accepts data from external source

- process the data it gets, for example filtering the data or modifying it

- produces information, for example AI created suggestions

- Stores Information on storage drives

6 0
2 years ago
Read 2 more answers
Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a
Viktor [21]

Answer:

The program to this question can be given as:

Program:

import java.util.*;

//import package for user input  

class Main     //define class

{

public static void main(String a[])  

//define main function

{

int positive_number=0,negative_number=0,count=0,num; //define variable

double total=0,avg=0;  

//creating Scanner class object.

Scanner ob = new Scanner(System.in);

System.out.println("Enter an integer, when done input 0: "); //message

num= ob.nextInt();

//taking input from user

if (num==0)  //check number equal to 0  

{  

System.out.println("No numbers are entered except 0"); //message

System.exit(1);

}

else

{

while (num!= 0)  

{    

   if (num> 0)

   {

positive_number++; // Increase positives

}

else

{

negative_number++; // Increase negatives

}

total=total+num; // Accumulate total

count++;    // Increase the count

num=ob.nextInt();

}

// Calculate the average

avg=total/count;

// Display values

System.out.println("The positive number is:"+positive_number);

System.out.println("The negatives number is:"+negative_number);

System.out.println("total is:"+total);

System.out.println("average is:"+avg);

}

}

}

Output:

Enter an integer, when done input 0: 22

2

1

4

0

The positive number is:4

The negatives number is:0

total is:29.0

average is:7.25

Explanation:

In the above program firstly we import the package for user input then we define a class that is main in this class we define the main method in the main method we define variable. Then we create a scanner class object for user input. In the number variable, we take multiple inputs from the user and also check that the user does not insert 0 at the starting of the program. To check this we use the condition statement that is a number equal to 0 then it will terminate the program. In the else part we first declare the loop that checks that inserted number is positive and negative and in this, we calculate the total of the numbers and at the end of the loop, we calculate the average of the number and print all the values.

4 0
2 years ago
Read 2 more answers
Other questions:
  • A(n) ____________________ stores copies of data or programs that are located on the hard drive and that might be needed soon in
    9·1 answer
  • Which network topology requires terminators at the ends of the backbone cable?
    6·1 answer
  • Answer these two if u can❤️
    5·2 answers
  • Who invented the Bluetooth device​
    12·1 answer
  • During system testing, developers test the program in an environment that is very similar to how the program will eventually be
    11·2 answers
  • A human subject’s photographs show two catchlights in each eye that are unwanted by the photographer. What is the most likely ca
    12·1 answer
  • What is the maximum ream size on an agile project?
    15·1 answer
  • Collaboration, listening, and negotiating are considered __________ skills.
    11·1 answer
  • Why would you use a computer's secondary memory?
    12·1 answer
  • I have all of the points and brainliest, but it won't level up, I don't know why, anyone know why?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!