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 large plate is fabricated from a steel alloy that has a plane strain fracture toughness of 78 MPa (70.98 ksi). If the plate is
Reika [66]

Answer:

minimum length of a surface crack is 15.043 mm

Explanation:

given data

strain fracture toughness K = 78 MPa

tensile stress = 345 MPa

Y = 1.04

to find out

minimum length of a surface crack

solution

we find here length of critical interior flaw from formula that is

α  =  \frac{1}{\pi} (\frac{K}{\sigma Y})^2     ....................1

put here value we get

α  =  \frac{1}{\pi} (\frac{78*\sqrt{10^3} }{345*1.04})^2

α  = 15.043 mm

so minimum length of a surface crack is 15.043 mm

7 0
3 years ago
A total of 245 kip force is applied to a set of 10 similar bolts. If the spring constant of each bolt is 0.4 Mlb/in and that of
zubka84 [21]

Answer: The net force in every bolt is 44.9 kip

Explanation:

Given that;

External load applied = 245 kip

number of bolts n = 10

External Load shared by each bolt (P_E) = 245/10 = 24.5 kip

spring constant of the bolt Kb = 0.4 Mlb/in

spring constant of members Kc = 1.6 Mlb/in

combined stiffness factor C = Kb / (kb+kc) = 0.4 / ( 0.4 + 1.6)  = 0.4 / 2 = 0.2 Mlb/in

Initial pre load Pi = 40 kip

now for Bolts; both pre load Pi and external load P_E are tensile in nature, therefore we add both of them

External Load on each bolt P_Eb = C × PE = 0.2 × 24.5 = 4.9 kip

So Total net Force on each bolt Fb = P_Eb + Pi

Fb = 4.9 kip + 40 kip

Fb = 44.9 kip

Therefore the net force in every bolt is 44.9 kip

4 0
3 years ago
9. A vehicle is having routine maintenance performed.
dexar [7]

Answer: b

Explanation:

8 0
3 years ago
Document the XSS stored exploit script: Use the View Source feature of the web page and create a screenshot of the few lines cod
Natali [406]

Answer:

Hold on let me ask my brother

Explanation:

5 0
3 years ago
The one end of a hollow square bar whose side is (10+N/100) in with (1+N/100) in thickness is under a tensile stress 102,500 psi
netineya [11]

Answer:

The one end of a hollow square bar whose side is (10+N/100) in wit

Explanation:

3 0
3 years ago
Other questions:
  • Which pendulum will.mobe faster​
    13·1 answer
  • 1. Computers are fully digital which means: A. They can’t convert things from analog B. They work only with numeric digits (base
    6·1 answer
  • What are the weight restrictions for a small UAS, including everything onboard at the time
    12·1 answer
  • python Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month an
    7·1 answer
  • A turboprop engine consists of a diffuser, compressor, combustor, turbine, and nozzle. The turbine drives a propeller as well as
    12·1 answer
  • A football player attempts a 30‐yd field goal. If he is able to impart a velocity u of 100 ft/sec to the ball, compute the minim
    6·1 answer
  • A hot plate with a temperature of 60 C, 50 triangular profile needle wings of length (54 mm), diameter 10 mm (k = 204W / mK) wil
    6·1 answer
  • Tech A says that proper footwear may include both leather and steel-toed shoes. Tech B says that when working in the shop, you o
    15·1 answer
  • One reason the shuttle turns on its back after liftoff is to give the pilot a view of the horizon. Why might this be useful?
    6·2 answers
  • What the minimum wire size for a general residential application on a 20 A circuit
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!