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
Slav-nsk [51]
3 years ago
9

Fibonacci sequence has many applications in Computer Science. Write a program to generate Fibonacci numbers as many as desired.

After the construction, you can print the sum value of the sequence. The example is below and user input is in boldface.
Engineering
2 answers:
VikaD [51]3 years ago
8 0

Answer:

The Python Code for Fibonacci Sequence is :

# Function for nth Fibonacci number  

def Fibonacci(n):  

if n<0:  

 print("Incorrect input")  

# First Fibonacci number is 0  

elif n==0:  

 return 0

# Second Fibonacci number is 1  

elif n==1:  

 return 1

else:  

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

# Driver Program  

print(Fibonacci(9))  

Explanation:

The Fibonacci numbers are the numbers in the following integer sequence.

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation

Fn = Fn-1 + Fn-2

with seed values

F0 = 0 and F1 = 1.

IrinaK [193]3 years ago
7 0
<h2>Answer:</h2>

//import the Scanner class

import java.util.Scanner;

public class FibonacciSeries {

   

   public static void main(String[] args) {

       

       //create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the number of terms

       System.out.println("Enter the number of terms");

       

       //Store the user input in a variable

       int noOfTerms = input.nextInt();

       

       //Create a variable sum to hold the sum of the series.

       int sum = 0;

       

       //Display message

       System.out.println("First " + noOfTerms + " terms of Fibonacci numbers are");

       

       //Create a loop that goes as many times as the number of terms

       //At every term (cycle), call the fibonacci method on the term.

       //And add the number to the sum variable

       for (int i = 1; i<=noOfTerms; i++){

         System.out.println(fibonacci(i));

         sum += fibonacci(i);

       }

       

       //Display a message

       System.out.println("The sum of the above sequence is ");

       

       //Display the sum of the fibonacci series

       System.out.println(sum);

   }

   

   //Create a method fibonacci to return the nth term of the fibonacci series

   public static int fibonacci(int n){

       

       //when n = 1, the fibonacci number is 0

       if (n <= 1){

           return 0;

       }

       

       //when n = 2, the fibonacci number is 1

       else if(n == 2){

           return 1;

       }

       

       //at other terms, fibonacci number is the sum of the previous two numbers

       else {

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

       }

       

   }     // End of fibonacci method

   

}        // End of class declaration

<h2>Sample Output:</h2><h2></h2>

>> Enter the number of terms

<u>7</u>

>> First 7 terms of Fibonacci numbers are

0

1

1

2

3

5

8

>> The sum of the above sequence is  

20

<h2>Explanation:</h2><h2></h2>

The above code has been written in Java. It contains comments explaining important parts of the code. Please go through the code through the comments for understandability.

You might be interested in
Outline the process used to test the following hypothesis: Titanium cages are stronger than steel cages for hockey goalie masks.
son4ous [18]

Answer:

true

Explanation:

8 0
3 years ago
Air enters the compressor of an air-standard Brayton cycle with a volumetric flow rate of 60 m3/s at 0.8 bar, 280 K. The compres
natima [27]

Answer:

a) The Net power developed in this air-standard Brayton cycle is 43.8MW

b) The rate of heat addition in the combustor is 84.2MW

c) The thermal efficiency of the cycle is 52%

Explanation:

To solve this cycle we need to determinate the enthalpy of each work point of it. If we consider the cycle starts in 1, the air is compressed until 2, is heated until 3 and go throw the turbine until 4.

Considering this:

h_{i} =T_{i}C_{pair}=T_{i}1.005\frac{KJ}{Kg K}

\mu_{comp}=\frac{h_{2S}-h_{1}}{h_{2}-h_{1}}

\mu_{comp}=\frac{h_{3}-h_{4}}{h_{3}-h_{4S}}

G_{m} =\frac{PMG_{v}}{TR} =59.73\frac{Kg}{s}

Now we can calculate the enthalpy of each work point:

h₁=281.4KJ/Kg

h₂=695.41KJ/Kg

h₃=2105KJ/Kg

h₄=957.14KJ/Kg

The net power developed:

P_{net}=P_{Tur}-P_{Comp}=G_{m}((h_{3}-h_{4})-(h_{2}-h_{1}))

The rate of heat:

Q=G_{m}(h_{3}-h_{2})

The thermal efficiency:

\mu_{ther}=\frac{P_{net}}{Q}

3 0
3 years ago
Riding a bike is an example of a procedural memory.
Viefleur [7K]

Answer:

True reading a bike would be an example of procedural memory

4 0
3 years ago
Read 2 more answers
If a weld is laying into a joint with a concave weld contour with undercutting issues, what might be the cause?
Katarina [22]

Answer:bbbb

Explanation:

4 0
3 years ago
What the different methods to turn on thyrister and how can a thyrister turned off​
myrzilka [38]

Answer:

forward voltage triggering

temperature triggering

dv/dt triggering

light triggering

gate triggering

Then turning off;

Turn off is accomplished by a "negative voltage" pulse between the gate and cathode terminals

Explanation:

hope it helps

8 0
3 years ago
Other questions:
  • Liquid water enters a valve at 300 kPa and exits at 275 kPa. As water flows through the valve, the change in its temperature, st
    10·1 answer
  • A(n)______ is a device used to ensure positive position of a valve or damper actuator A. calibrator B. positioner C. actuator D.
    6·1 answer
  • A Si sample contains 1016 cm-3 In acceptor atoms and a certain number of shallow donors, the In acceptor level is 0.16 eV above
    5·2 answers
  • What is your employer required to have on fixed ladders that extend more than 24 feet in the workplace?
    15·2 answers
  • I WILL GIVE BRAINLIEST IF ANSWER FAST What is the measurement on this Dial Caliper?
    9·1 answer
  • 500 flights land each day at San Jose’s airport. Assume that each flight has a 5% chance of being late, independently of whether
    5·1 answer
  • How many kg / day of NaOH must be added to neutralize a waste stream generated by an industry producing 90,800 kg / day of sulfu
    6·2 answers
  • QUESTÃO 13. Explique o uso das aspas no trecho "Darei a cada uma de vocês
    12·1 answer
  • Which option explains why Tyler is impressed in the following scenario?
    10·2 answers
  • Your friend has two substances A and B which are compressed liquid and superheated vapor respectively. Both are in rigid vessels
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!