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 3-ft-diameter vertical cylindrical tank open to the atmosphere contains 1-ft-high water. The tank is now rotated about the cen
arlik [135]

Answer:

The angular velocity is 7.56 rad/s

the maximum water height is 2 ft

Explanation:

The z-position as a function of r is equal to

z_{s(r)} =h_{0} -\frac{w^{2}(R^{2}-2r^{2}   }{4g} (eq. 1)

where

h0 = initial height = 1 ft

w = angular velocity

R = radius of the cylinder = 1.5 ft

zs(r) = 0 when the free surface is lowest at the centre

Replacing and clearing w

w=\sqrt{\frac{4gh_{0} }{R^{2} } } =\sqrt{\frac{4*32.17*1}{1.5^{2} } } =7.56rad/s

if you consider the equation 1 for the free surface at the edge is equal to

z_{s(R)} =h_{0} +\frac{w^{2}R^{2}   }{4g} =1+\frac{(7.56^{2})*(1.5^{2} ) }{4*32.17} =1.99ft=2ft

7 0
3 years ago
X cotx expansion using maclaurins theorem.
Lemur [1.5K]

It is to be noted that it is impossible to find the Maclaurin Expansion for F(x) = cotx.

<h3>What is Maclaurin Expansion?</h3>

The Maclaurin Expansion is a Taylor series that has been expanded around the reference point zero and has the formula f(x)=f(0)+f′. (0) 1! x+f″ (0) 2! x2+⋯+f[n](0)n!

<h3>What is the explanation for the above?</h3>

as indicated above, the Maclaurin infinite series expansion is given as:

F(x)=f(0)+f′. (0) 1! x+f″ (0) 2! x2+⋯+f[n](0)n!

If F(0) = Cot 0

F(0) = ∝ = 1/0

This is not definitive,

Hence, it is impossible to find the Maclaurin infinite series expansion for F(x) = cotx.

Learn more about Maclaurin Expansion at;
brainly.com/question/7846182
#SPJ1

4 0
1 year ago
weight of 1000 pounds is suspended from two cables. The allowable stress in the cables is 1500 psi. Find the minimum diameter fo
kari74 [83]

Answer:

The minimum diameter for each cable should be 0.65 inches.

Explanation:

Since, the load is supported by two ropes and the allowable stress in each rope is 1500 psi. Therefore,

(1/2)(Weight/Cross Sectional Area) = Allowable Stress

Here,

Weight = 1000 lb

Cross-sectional area = πr²

where, r = minimum radius for each cable

(1/2)(1000 lb/πr²) = 1500 psi

500 lb/1500π psi = r²

r = √1.061 in²

r = 0.325 in

Now, for diameter:

Diameter = 2(radius) = 2r

Diameter = 2(0.325 in)

<u>Diameter = 0.65 in</u>

7 0
2 years ago
Two vehicles arrive at an uncontrolled intersection from different streets at the same time 1.The driver on the right must yield
ss7ja [257]
3. Both vehicles must stop
4 0
3 years ago
Railroad tracks made of 1025 steel are to be laid during the time of year when the temperature averages 4C (40F). Of a joint spa
DENIUS [597]

Answer:

41.5° C

Explanation:

Given data :

1025 steel

Temperature = 4°C

allowed joint space = 5.4 mm

length of rails = 11.9 m

<u>Determine the highest possible temperature </u>

coefficient of thermal expansion ( ∝ ) = 12.1 * 10^-6 /°C

Applying thermal strain ( Δl / l )  = ∝ * ΔT

                                    ( 5.4 * 10^-3 / 11.9 )  = 12.1 * 10^-6 * ( T2 - 4 )

∴  ( T2 - 4 ) =  ( 5.4 * 10^-3 / 11.9 ) / 12.1 * 10^-6

hence : T2 = 41.5°C

8 0
2 years ago
Other questions:
  • . Using the Newton Raphson method, determine the uniform flow depth in a trapezoidal channel with a bottom width of 3.0 m and si
    11·1 answer
  • Differentiate between "Threshold and Resolution" with suitable examples.
    12·1 answer
  • Identify each statement as referring to a series or parallel circuit.
    15·1 answer
  • Which of the two materials (brittle vs. ductile) usually obtains the highest ultimate strength and why?
    5·1 answer
  • Una empresa realizó en el ejercicio de compras al contado por valor
    9·1 answer
  • Please help me fast, I don’t have time
    15·1 answer
  • An inventor tries to sell you his new heat engine that takes in 40 J of heat at 87°C on each cycle, expels 30 J at 27°C, and doe
    14·1 answer
  • 6-What is the difference between the critical point and the triple point?
    15·2 answers
  • Its been days wsgggggg
    12·2 answers
  • The controller determines if a(n) _________ exists by calculating the difference between the SP and the PV.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!