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
Convert 250 lb·ft to N.m. Express your answer using three significant figures.
vfiekz [6]

Answer:

It will be equivalent to 338.95 N-m

Explanation:

We have to convert 250 lb-ft to N-m

We know that 1 lb = 4.45 N

So foe converting from lb to N we have to multiply with 4.45

So 250 lb = 250×4.45 =125 N

And we know that 1 feet = 0.3048 meter

Now we have to convert 250 lb-ft to N-m

So 250lb-ft=250\times 4.45N\times 0.348M=338.95N-m

So 250 lb-ft = 338.95 N-m

6 0
3 years ago
What is the weight density of a 2.24 in diameter titanium sphere that weights 0.82 lb?
nasty-shy [4]

Answer:

0.14\ lb/in^{3}

Explanation:

Density is defined as mass ler unit volume, expressed as

\rho=\frac {m}{v}

Where m is mass, \rho is density and v is the volume. For a sphere, volume is given as

v=\frac {4\pi r^{3}}{3}

Replacing this into the formula of density then

\rho=\frac {m}{\frac {4\pi r^{3}}{3}}

Given diameter of 2.24 in then the radius is 1.12 in. Substituting 0.82 lb for m then

\rho=\frac {0.82}{\frac {4\pi 1.12^{3}}{3}}=0.13932044952427\approx 0.14 lb/in^{3}

4 0
4 years ago
2 Air enters the compressor of a cold air-standard Brayton cycle at 100 kPa, 300 K, with a mass flow rate of 6 kg/s. The compres
lutik1710 [3]
You can see and download from the link

https://tlgur.com/d/GYYVL5lG

Please don't forget to put heart ♥️
5 0
3 years ago
Batteries typically have ratings stated in ampere-hours, that let you estimate the length of time any particular current level c
DerKrebs [107]

Answer: attached

Explanation:

6 0
3 years ago
7. A single-pole GFCI breaker is rated at
soldi70 [24.7K]
The answer to this question is C
3 0
3 years ago
Other questions:
  • A 356 cast aluminum test bar is tested in tension. The initial gage length as marked on the sample is 50mm and the initial diame
    9·1 answer
  • Consider a variant of the thermostat of example 3.5. In this variant, there is only one temperature threshold, and to avoid chat
    6·2 answers
  • Pam, when she turned 25, made an investment of $20,000 at an interest rate of 6.5% compounded semi-annually. Now that she is 50
    8·1 answer
  • Patient people vote more often than non-patient people.<br> True<br> O<br> False
    8·1 answer
  • Consider a new peer Alice that joins BitTorrent without possessing any chunks. Without any chunks,she cannot become a top-four u
    9·1 answer
  • Suggest a data structure that supports the following operations on the grades that a student at the university receives. Assume
    5·1 answer
  • The Torricelli's theorem states that the (velocity—pressure-density) of liquid flowing out of an orifice is proportional to the
    5·1 answer
  • A phase angle in the frequency domain corresponds to
    12·1 answer
  • Give three examples of how engineering has made human life better in your opinion.
    13·1 answer
  • Which of the following scenarios describes an advantage of a global economy?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!