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 geothermal heat pump absorbs 15 KJ/s of heat from the Earth 15 m below a house. This heat pump uses a 7.45 kJ/s compressor.
Oxana [17]

Answer:

COP of heat pump=3.013

COP of cycle=1.124

Explanation

W = Q2 - Q1 ----- equation 1

W = work done

Q2 = final energy

Q1 = initial energy

A) calculate the COP of the heat pump

COP =Q2/W

from equation 1

Q2 = Q1 + W = 15 + 7.45 = 22.45 KW

therefore COP =22.45/7.45  = 3.013

B) COP when cycle is reversed

COP = Q1/W

from equation 1

Q1 + W = Q2 ------ equation 2

Q2 = 15 Btu/s = 15 * 1.055 = 15.825 KW therefore from equation 2

Q1 = 8.375 KW

COP =8.375/7.45   = 1.124

6 0
3 years ago
Read 2 more answers
Energy that causes a transfer of heat between marterials
notsponge [240]

Thermal radiation is a form of heat transfer because the electromagnetic radiation emitted from the source carries energy away from the source to surrounding (or distant) objects.

I tried, but I hope this helps :)

4 0
3 years ago
(a) Determine the dose (in mg/kg-day) for a bioaccumulative chemical with BCF = 103 that is found in water at a concentration of
solmaris [256]

Answer:

0.064 mg/kg/day

6.25% from water, 93.75% from fish

Explanation:

Density of water is 1 kg/L, so the concentration of the chemical in the water is 0.1 mg/kg.

The BCF = 10³, so the concentration of the chemical in the fish is:

10³ = x / (0.1 mg/kg)

x = 100 mg/kg

For 2 L of water and 30 g of fish:

2 kg × 0.1 mg/kg = 0.2 mg

0.030 kg × 100 mg/kg = 3 mg

The total daily intake is 3.2 mg.  Divided by the woman's mass of 50 kg, the dosage is:

(3.2 mg/day) / (50 kg) = 0.064 mg/kg/day

b) The percent from the water is:

0.2 mg / 3.2 mg = 6.25%

And the percent from the fish is:

3 mg / 3.2 mg = 93.75%

3 0
3 years ago
A large tank is filled to capacity with 500 gallons of pure water. Brine containing 2 pounds of salt per gallon is pumped into t
Nataly [62]

Answer:

A) A(t) = 10(100 - t) + c(100 - t)²

B) Tank will be empty after 100 minutes.

Explanation:

A) The differential equation of this problem is;

dA/dt = R_in - R_out

Where;

R_in is the rate at which salt enters

R_out is the rate at which salt exits

R_in = (concentration of salt in inflow) × (input rate of brine)

We are given;

Concentration of salt in inflow = 2 lb/gal

Input rate of brine = 5 gal/min

Thus;

R_in = 2 × 5 = 10 lb/min

Due to the fact that the solution is pumped out at a faster rate, thus it is reducing at the rate of (5 - 10)gal/min = -5 gal/min

So, after t minutes, there will be (500 - 5t) gallons in the tank

Therefore;

R_out = (concentration of salt in outflow) × (output rate of brine)

R_out = [A(t)/(500 - 5t)]lb/gal × 10 gal/min

R_out = 10A(t)/(500 - 5t) lb/min

So, we substitute the values of R_in and R_out into the Differential equation to get;

dA/dt = 10 - 10A(t)/(500 - 5t)

This simplifies to;

dA/dt = 10 - 2A(t)/(100 - t)

Rearranging, we have;

dA/dt + 2A(t)/(100 - t) = 10

This is a linear differential equation in standard form.

Thus, the integrating factor is;

e^(∫2/(100 - t)) = e^(In(100 - t)^(-2)) = 1/(100 - t)²

Now, let's multiply the differential equation by the integrating factor 1/(100 - t)².

We have;

So, we ;

(1/(100 - t)²)(dA/dt) + 2A(t)/(100 - t)³ = 10/(100 - t)²

Integrating this, we now have;

A(t)/(100 - t)² = ∫10/(100 - t)²

This gives;

A(t)/(100 - t)² = (10/(100 - t)) + c

Multiplying through by (100 - t)²,we have;

A(t) = 10(100 - t) + c(100 - t)²

B) At initial condition, A(0) = 0.

So,0 = 10(100 - 0) + c(100 - 0)²

1000 + 10000c = 0

10000c = -1000

c = -1000/10000

c = -0.1

Thus;

A(t) = 10(100 - t) + -0.1(100 - t)²

A(t) = 1000 - 10t - 0.1(10000 - 200t + t²)

A(t) = 1000 - 10t - 1000 + 20t - 0.1t²

A(t) = 10t - 0.1t²

Tank will be empty when A(t) = 0

So, 0 = 10t - 0.1t²

0.1t² = 10t

Divide both sides by 0.1t to give;

t = 10/0.1

t = 100 minutes

6 0
3 years ago
A bridge to be fabricated of steel girders is designed to be 500 m long and 12 m wide at ambient temperature (assumed 20°C). Exp
Volgvan

Answer:

a) 22.5number

b) 22.22 m length

Explanation:

Given data:

Bridge length = 500 m

width of bridge = 12 m

Maximum temperature = 40 degree C

minimum temperature  = - 35 degree C

Maximum expansion can be determined as

\Delta L = L \alpha (T_{max} - T_{min})

where , \alpha is expansion coefficient = 12\times 10^{-6} degree C

SO, \Delta L = 500\times 12\times 10^{-6}\times ( 40 - (-35))

\Delta L = 0.45 m = 450 mm

number of minimum expansion joints is calculated as

n = \frac{450}{20} = 22.5

b) length of each bridge

Length = \frac{500}{22.5} = 22.22 m

8 0
2 years ago
Other questions:
  • When a mesh in a circuit contains an independent or dependent current source, this leads to a special case of mesh-current analy
    14·1 answer
  • The army has cars and boats etc right
    7·1 answer
  • A 5000-lb truck is being used to lift a 1000-lb boulder B that is on a 200-lb pallet A. Knowing that the truck starts from rest
    8·1 answer
  • I need answers for this sheet please.
    15·1 answer
  • A weighted, frictionless piston-cylinder device initially contains 5.25 kg of R134a as saturated vapor at 500 kPa. The container
    7·1 answer
  • A soil element is subjected to a minor principle stress of 50 kPa on a plane rotated 20 ° counterclockwise from vertical. If the
    10·1 answer
  • Answer the following questions about your own experience in the labor force.
    15·1 answer
  • What invention of the Middle Ages contributed to making books easily available?
    15·1 answer
  • A driver complains that his front tires are wearing
    14·1 answer
  • Planetary gears require the armature to be offset via a gear housing that holds the starter drive.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!