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 circular section of material is tested. The original specimen is 200 mm long and has a diameter of 13 mm. When loaded to its p
n200080 [17]

Answer:

modulus of elasticity = 100.45 Gpa,

proportional limit = 150.68 N/mm^2.

Explanation:

We are given the following parameters or data in the question as;

=> "The original specimen = 200 mm long and has a diameter of 13 mm."

=> "When loaded to its proportional limit, the specimen elongates by 0.3 mm."

=> " The total axial load is 20 kN"

Step one: Calculate the area

Area = π/ 4 × c^2.

Area = π/ 4 × 13^2 = 132.73 mm^2.

Step two: determine the stress induced.

stress induced = load/ area= 20 × 1000/132.73 = 150.68 N/mm^2.

Step three: determine the strain rate:

The strain rate = change in length/original length = 0.3/ 200 = 0.0015.

Step four: determine the modulus of elasticity.

modulus of elasticity = stress/strain = 150.68/0.0015 = 100453.33 N/mm^2 = 100.45 Gpa.

Step five: determine the proportional limit.

proportional limit = 20 × 1000/132.73 = 150.68 N/mm^2.

7 0
3 years ago
Read 2 more answers
A piston-cylinder device contains an ideal gas mixture of 3 kmol of He gas and 7 kmol of Ar gas (both gases are monatomic) at 27
lidiya [134]

Answer:

Q = 62    ( since we are instructed not to include the units in the answer)

Explanation:

Given that:

n_{HCl} = 3 \ kmol\\n_{Ar} = 7 \ k mol

T_1 = 27^0 \ C = ( 27+273)K =  300 K

P_1 = 200 \ kPa

Q = ???

Now the gas expands at constant pressure until its volume doubles

i.e if V_1 = x\\V_2 = 2V_1

Using Charles Law; since pressure is constant

V \alpha T

\frac{V_2}{V_1}  =\frac{T_2}{T_1}

\frac{2V_1}{V_1}  =\frac{T_2}{300}

T_2 = 300*2\\T_2 = 600

mass of He =number of moles of He × molecular weight of He

mass of He = 3 kg  × 4

mass of He = 12 kg

mass of Ar =number of moles of Ar × molecular weight of Ar

mass of He = 7 kg  × 40

mass of He = 280 kg

Now; the amount of  Heat  Q transferred = m_{He}Cp_{He} \delta T  + m_{Ar}Cp_{Ar} \delta T

From gas table

Cp_{He} = 5.9 \ kJ/Kg/K\\Cp_{Ar}  = 0.5203 \  kJ/Kg/K

∴ Q = 12*5.19*10^3(600-300)+280*0.5203*10^3(600-300)

Q = 62.389 *10^6

Q = 62 MJ

Q = 62    ( since we are instructed not to include the units in the answer)

5 0
3 years ago
Read 2 more answers
Infinitivo de vivia kkk xd
blagie [28]

Answer:

pls put a question not random letters

Explanation:

8 0
3 years ago
Which of the following is an example of a hardwood? A maple B spruce C pine D fir
bearhunter [10]

Answer:

A. Maple

Explanation:

Maple is a hardwood.

Hope that helps!

7 0
2 years ago
For an isotropic material, E and ν are often chosen as the two independent engineering constants. There are other elastic consta
pav-90 [236]

Answer:

khgy

Explanation:

nbv

8 0
3 years ago
Other questions:
  • A groundwater contains the following cations (expressed as the cation):
    5·2 answers
  • Are you able to text without looking at your phone?
    10·1 answer
  • Give an example of how the fields of science, technology, and mathematics are commonly used when building a highway.
    7·1 answer
  • Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.
    11·1 answer
  • A train which is traveling at 70 mi/hr applies its brakes as it reaches point A and slows down with a constant deceleration. Its
    12·1 answer
  • Which of these are an ethical issue
    14·1 answer
  • Please help is due tonight
    6·2 answers
  • When was solar power envold ​
    8·2 answers
  • What is shown in the above figure
    11·1 answer
  • Which type of Artificial Intelligence (AI) can repeatedly perform tasks of limited scope?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!