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
A 0.50 m3 drum was filled with 0.49 m3 of liquid water at 25oC and the remaining volume was water vapor without any air. The dru
timurjin [86]

Answer:

There is not going to be pressure build up in the  system,that is isobaric process.

Explanation:

Assumptions to be made

1.  No mass is gained or lost during the heating process.

2. There are no friction losses,so work is transmitted efficiently.

3. It was started the water in the drum and its surrounding have same temperature.

4. This system is closed,so there is no mass transfer across its boundaries.

5 0
3 years ago
A cylindrical 1045 steel bar is subjected to repeated compression-tension stress cycling along its axis. If the load amplitude i
Gre4nikov [31]

Answer:

13.4 mm

Explanation:

Given data :

Load amplitude ( F )  = 22,000 N

factor of safety ( N )= 2.0

Take ( Fatigue limit stress amplitude for this alloy ) б = 310 MPa

<u>calculate the minimum allowable bar diameter to ensure that fatigue failure will not occur</u>

minimum allowable bar diameter = 13.4 * 10^-3 m ≈ 13.4 mm

<em>attached below is a detailed solution</em>

3 0
2 years ago
Which permission do you need to shoot on the owner’s property?
Elena L [17]

Answer:

filming permit,

( MARK ME BRAINLIEST!!)

4 0
3 years ago
The autorotation spin characteristics of a straight-wing aircraft are induced by Group of answer choices
NemiM [27]

Answer:

More Drag on the down going wing and More Lift on the up going wing

Explanation:

The autorotation spins of blades used in airborne wind energy technology sectors help drive and move the winds and water propeller-type turbines or shafts of generators to produce electricity at altitude and transmit the electricity to earth through conductive tethers.

Sometimes autorotation takes place in rotating parachutes, kite tails. Etc.

As a result, more Drag usually induces the autorotation spin characteristics of a straight-wing aircraft on the downgoing wing and More Lift on the up-going wing.

7 0
3 years ago
What happens in double transverse wishbone front suspension when brakes are applied.
RideAnS [48]

Answer:

When the brakes are applied the in the typical double transverse wishbone front suspension,  it "drives" the car ground due to the setting of the link-type system pivot points on the lower wishbone are have parallel alignment to the road

Explanation:

In order to minimize the car's reaction to the application of the brakes, the front and rear pivot are arranged with the lower wishbone's rear pivot made to be higher than the front pivot as such the inclined wishbone torque results in an opposing vertical force to the transferred extra weight from the back due to breaking.

5 0
3 years ago
Other questions:
  • Using Von Karman momentum integral equation, find the boundary layer thickness, the displacement thickness, the momentum thickne
    14·1 answer
  • Find the equivalent impedance Zeq seen by the source when Vs = 2 cos (5t) v, C = 0.2 F, R = 1 Ω and L = 0.1 H. (Give angles in d
    12·1 answer
  • Write a matrix, that is a lower triangular matrix.
    15·1 answer
  • 3.24 Program: Drawing a half arrow (Java) This program outputs a downwards facing arrow composed of a rectangle and a right tria
    12·1 answer
  • How do people eat with there noses shut
    12·2 answers
  • What are the four types of physical hazards?
    13·2 answers
  • A wing generates a lift L when moving through sea-level air with a velocity U. How fast must the wing move through the air at an
    7·1 answer
  • Three-dimensional measuring references all of these EXCEPT:
    10·1 answer
  • A driver is traveling at 90 km/h down a 3% grade on good, wet pavement. An accident
    11·1 answer
  • What is the importance of the causal link<br> in work accidents?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!