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
Consider a sinusoidal oscillator consisting of an amplifier having a frequency-independent gain A (where A is positive) and a se
mafiozo [28]

Sinusoidal oscillator frequency of oscillation is given below.

Explanation:

The criterion for a stable oscillator is given in the equation

l A(jw)β(jw) l ≥ 1

In this task A represents the gain of the amplifier , and

β represents gain/attenuation of the second-order bandpass filter.

This sinusoidal oscillation is a special edge case where the product is equal to one.

So the condition is A-K=1

to obtain the sustained oscillations at the desired frequency of oscillations, the product of the voltage gain A and the feedback gain β must be one or greater than one. In this case, the amplifier gain A must be 3. Hence, to satisfy the product condition, feedback gain β must be 1/3.

4 0
3 years ago
Explain the two advantages and the two disadvantages of fission as an energy source.
yawa3891 [41]

Answer with Explanation:

1) The advantages of fission energy are:

a) Higher concentration of energy : Concentration of energy or the energy density is defined as the amount of energy that is produced by burning a unit mass of the fuel. The nuclear energy obtained by fission has the highest energy density among all the other natural sources of energy such as coal,gas,e.t.c.

b) Cheap source of energy : The cost at which the energy is produced by a nuclear reactor after it is operational is the lowest among all the other sources of energy such as coal, solar,e.t.c

2) The disadvantages of fission energy are:

a) Highly dangerous residue: The fuel that is left unspent is highly radioactive and thus is very dangerous. Usually the residual material is taken deep into the earth for it's disposal.

b) It has high initial costs of design and development: The cost to design a nuclear reactor and to built one after it is designed is the most among all other types of energy sources and requires highly skilled personnel for operation.

6 0
3 years ago
The solid cylinders AB and BC are bonded together at B and are attached to fixed supports at A and C. The modulus of rigidity is
romanna [79]

Answer:

a) 0.697*10³ lb.in

b) 6.352 ksi

Explanation:

a)

For cylinder AB:

Let Length of AB = 12 in

c=\frac{1}{2}d=\frac{1}{2} *1.1=0.55in\\ J=\frac{\pi c^4}{2}=\frac{\pi}{2}0.55^4=0.1437\ in^4\\

\phi_B=\frac{T_{AB}L}{GJ}=\frac{T_{AB}*12}{3.3*10^6*0.1437}  =2.53*10^{-5}T_{AB}

For cylinder BC:

Let Length of BC = 18 in

c=\frac{1}{2}d=\frac{1}{2} *2.2=1.1in\\ J=\frac{\pi c^4}{2}=\frac{\pi}{2}1.1^4=2.2998\ in^4\\

\phi_B=\frac{T_{BC}L}{GJ}=\frac{T_{BC}*18}{5.9*10^6*2.2998}  =1.3266*10^{-6}T_{BC}

2.53*10^{-5}T_{AB}=1.3266*10^{-6}T_{BC}\\T_{BC}=19.0717T_{AB}

T_{AB}+T_{BC}-T=0\\T_{AB}+T_{BC}=T\\T_{AB}+T_{BC}=14*10^3\ lb.in\\but\ T_{BC}=19.0717T_{AB}\\T_{AB}+19.0717T_{AB}=14*10^3\\20.0717T_{AB}=14*10^3\\T_{AB}=0.697*10^3\ lb.in\\T_{BC}=13.302*10^3\ lb.in

b) Maximum shear stress in BC

\tau_{BC}=\frac{T_{BC}}{J}c=13.302*10^3*1.1/2.2998=6.352\ ksi

Maximum shear stress in AB

\tau_{AB}=\frac{T_{AB}}{J}c=0.697*10^3*0.55/0.1437=2.667\ ksi

8 0
3 years ago
The liquid-phase reaction:
OLEGan [10]

Answer:

attached below

Explanation:

4 0
3 years ago
Situation: Peter is designing a new hybrid car that functions on solar power. He is currently working on sketches of his design
givi [52]

Answer:

whats the question?

Explanation:

8 0
2 years ago
Other questions:
  • Consider the following class definitions: class smart class superSmart: public smart { { public: public: void print() const; voi
    6·1 answer
  • Technician A says a basic circuit problem can be caused by something in the circuit that increases voltage. Technician B says a
    8·1 answer
  • A four-lane freeway (two lanes in each direction) is located on rolling terrain and has 12-ft lanes, no lateral obstructions wit
    14·1 answer
  • . A piston-cylinder device whose piston is resting on top of a set of stops initially contains 0.5 kg of helium gas at 100 kPa a
    14·1 answer
  • Write a function called arraySum() that takes two arguments: an integer array and the number of elements in the array. Have the
    14·1 answer
  • A water agency stated that waterlines cannot have water flowing faster than 8 ft/s. What is the minimum standard pipe diameter t
    12·1 answer
  • MCQ : What are the main the constituents of acid rains?
    10·2 answers
  • Select the correct answer.
    6·1 answer
  • All of the following are drum brake components mounted to the backing plate, EXCEPT:
    12·1 answer
  • Which one of the following best defines hardness: (a) energy absorbed by a material when an object strikes its surface, (b) resi
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!