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
Before a rotameter can be used to measure an unknown flow rate, a calibration curve of flow rate versus rotameter reading must b
allochka39001 [22]
This statement is b which is true: hope this helped
6 0
3 years ago
3.3 Equation (2) for VCPP is rather difficult to prove at this time. Take it as a challenge to derive it as you learn increasing
podryga [215]

Answer:

For an RC integrator circuit, the input signal is applied to the resistance with the output taken across the capacitor, then VOUT equals VC. As the capacitor is a frequency dependant element, the amount of charge that is established across the plates is equal to the time domain integral of the current. That is it takes a certain amount of time for the capacitor to fully charge as the capacitor can not charge instantaneously only charge exponentially.

Therefore the capacitor current can be written as:

 

his basic equation above of iC = C(dVc/dt) can also be expressed as the instantaneous rate of change of charge, Q with respect to time giving us the following standard equation of: iC = dQ/dt where the charge Q = C x Vc, that is capacitance times voltage.

The rate at which the capacitor charges (or discharges) is directly proportional to the amount of the resistance and capacitance giving the time constant of the circuit. Thus the time constant of a RC integrator circuit is the time interval that equals the product of R and C.

Since capacitance is equal to Q/Vc where electrical charge, Q is the flow of a current (i) over time (t), that is the product of i x t in coulombs, and from Ohms law we know that voltage (V) is equal to i x R, substituting these into the equation for the RC time constant gives:

We have seen here that the RC integrator is basically a series RC low-pass filter circuit which when a step voltage pulse is applied to its input produces an output that is proportional to the integral of its input. This produces a standard equation of: Vo = ∫Vidt where Vi is the signal fed to the integrator and Vo is the integrated output signal.

The integration of the input step function produces an output that resembles a triangular ramp function with an amplitude smaller than that of the original pulse input with the amount of attenuation being determined by the time constant. Thus the shape of the output waveform depends on the relationship between the time constant of the circuit and the frequency (period) of the input pulse.

By connecting two RC integrator circuits together in parallel has the effect of a double integration on the input pulse. The result of this double integration is that the first integrator circuit converts the step voltage pulse into a triangular waveform and the second integrator circuit converts the triangular waveform shape by rounding off the points of the triangular waveform producing a sine wave output waveform with a greatly reduced amplitude.

RC Differentiator

For a passive RC differentiator circuit, the input is connected to a capacitor while the output voltage is taken from across a resistance being the exact opposite to the RC Integrator Circuit.

A passive RC differentiator is nothing more than a capacitance in series with a resistance, that is a frequency dependentTherefore the capacitor current can be written as:

 

 

device which has reactance in series with a fixed resistance (the opposite to an integrator). Just like the integrator circuit, the output voltage depends on the circuits RC time constant and input frequency.

Thus at low input frequencies the reactance, XC of the capacitor is high blocking any d.c. voltage or slowly varying input signals. While at high input frequencies the capacitors reactance is low allowing rapidly varying pulses to pass directly from the input to the output.

This is because the ratio of the capacitive reactance (XC) to resistance (R) is different for different frequencies and the lower the frequency the less output. So for a given time constant, as the frequency of the input pulses increases, the output pulses more and more resemble the input pulses in shape.

We saw this effect in our tutorial about Passive High Pass Filters and if the input signal is a sine wave, an rc differentiator will simply act as a simple high pass filter (HPF) with a cut-off or corner frequency that corresponds to the RC time constant (tau, τ) of the series network.

Thus when fed with a pure sine wave an RC differentiator circuit acts as a simple passive high pass filter due to the standard capacitive reactance formula of XC = 1/(2πƒC).

But a simple RC network can also be configured to perform differentiation of the input signal. We know from previous tutorials that the current through a capacitor is a complex exponential given by: iC = C(dVc/dt). The rate at which the capacitor charges (or discharges) is directly proportional to the amount of resistance and capacitance giving the time constant of the circuit. Thus the time constant of a RC differentiator circuit is the time interval that equals the product of R and C. Consider the basic RC series circuit below.

Explanation:

3 0
3 years ago
What is a material safety data sheet? A. a categorized list of hazardous substances in an industry B. a document with safety inf
horsena [70]

Answer: A.

Explanation:

safety data sheet are documents that list information relating to occupational safety and health for the use of various substances and products.

3 0
3 years ago
A particle moves along a straight line with a velocity V=(200s) mm/s, where s is in millimeters. Determine acceleration of the p
iragen [17]

Answer:

200 mm/s²

Explanation:

See it in the pic

8 0
3 years ago
You buy a 75-W lightbulb in Europe, where electricity is delivered to homes at 240V. If you use the lightbulb in the United Stat
givi [52]

Answer:

The bulb will be \frac{1}{4} times as bright as it is in Europe.

Explanation:

Data provided in the question:

Power of bulb in Europe = 75 W

Voltage provided in Europe = 240 V

Voltage provided in United Stated = 120 V

Now,

We know,

Power = Voltage² ÷ Resistance

Therefore,

75 = 240² ÷ Resistance

or

Resistance = 240² ÷ 75

or

Resistance = 768 Ω

Therefore,

Power in United States = Voltage² ÷ Resistance

= 120² ÷ 768

= 18.75 W

Therefore,

Ratio of powers

\frac{\text{Power in united states}}{\text{Power in Europe}}=\frac{18.75}{75}

= \frac{1}{4}

Hence,

The bulb will be \frac{1}{4} times as bright as it is in Europe.

7 0
3 years ago
Other questions:
  • The difference between ideal voltage source and the ideal current source​
    7·2 answers
  • The inlet and exhaust flow processes are not included in the analysis of the Otto cycle. How do these processes affect the Otto
    6·1 answer
  • What is the definition of a tolerance on a dimension typically found on technical drawings?
    7·1 answer
  • A well-insulated tank in a vapor power plant operates at steady state. Saturated liquid water enters at inlet 1 at a rate of 125
    8·1 answer
  • Asolid rectangular rodhas a length of 90mm, made of steel material (E =207,000 MPa, Syield= 300 MPa), the cross section of the r
    14·1 answer
  • You’re going to write a program that models the Littleton City Lotto (not a real Lotto game). The program is going to allow to u
    6·1 answer
  • What prevented this weld from becoming ropey?
    13·2 answers
  • Implement a program that manages shapes. Implement a class named Shape with a method area() which returns the double value 0.0.
    8·1 answer
  • Nancy wants to buy a cooking stove that’s electrically insulated and resistant to heat. What material should she choose for the
    13·1 answer
  • technician a says that the higher the gear selected the more torque is available. technician b says that a transaxle contains ge
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!