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
IRISSAK [1]
3 years ago
12

The Fibonacci sequence starts 1, 1, 2, 3, 5, 8, .. . . Each number in the se-quence (after the first two) is the sum of the prev

ious two. Write a pro-gram that computes and outputs the nth Fibonacci number, where n is avalue entered by the user.
Computers and Technology
1 answer:
dem82 [27]3 years ago
5 0

Answer:

value=int(input("Enter the number up-to the user wants the Fibonacci series: "))

a=0

b=1

c=1

for x in range(value):

   print(c,end=" ")

   c=a+b

   a=b

   b=c

Output :

  • If the user input 5, then the output is "1 1 2 3 5".
  • If the user input 10, then the output is "1 1 2 3 5 8 13 21 34 55".

Explanation:

  • The above defined a python program which is used for the Fibonacci series.
  • The first line of the program is used to instruct the user and take the input from the user.
  • Then the for loop executes up-to that range value.
  • Then in the for-loop, the two variable needs to store the current value and previous value which is used to give the series after addition.
You might be interested in
Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
erastova [34]

If Seneca has not done anything since the conditional formatting she can undo what her last action was. This is done by either pressing control+Z or by clicking on the undo icon.

If other actions have been done, there are a few more steps that need to be taken in order to clear the formatting. They are:

1. Select the cell or cells whose formatting you want to delete.

2. Display the Home tab of the ribbon.

3. In the Editing group, click Clear | Clear Formats.

8 0
3 years ago
Write a full class definition for a class named Player , and containing the following members:
Paraphin [41]

Answer:

I used C++ to implement this program using dev c++, however, i defined the public method inside the class. The code with illustration of this question is given in section phase. If you want to define the classes outside from class then you can use scope resolution operator to access the method of the class. However, the complete running code is given below in <em>explanation </em>section

Explanation:

#include <iostream>// included preprocessor directive

using namespace std;

class player// class player is started from here

{

private:// class varaibles are set at here and scope of varialbe is private.

 string name;//variable for getting and setting name of player

 int score;//variable for getting and setting score of player

 

public:// declaring public method that can be accessbile outside of class but in this program

 void setName (string name)// public method for setting name of player

{

 this->name=name;// name is initialized by paramenter name to variable name

}

 void setScore(int score)//publice method for setting score of player

{

 this->score=score;

}

int getScore()// public method for getting score of player

{

 return score;// on call, return the score of player

}

string getName()// public method for getting name of player

{

 return name;// return player name;

}

 

};//end of class "player"

int main()//main function get executed

{

   player firstPlayer;//class object "firstPlayer" is created

firstPlayer.setName("Renaldo");// firstPlayer name is initialized

firstPlayer.setScore(500);// assgined score to firstPlayer

string getname=firstPlayer.getName();// get name of firstPlayer

int getscore=firstPlayer.getScore();//get score of firstPlayer

cout<<getname;//print name of firstPlayer

cout<<"\n";//line break

cout<<getscore;//print score of firstPlayer

cout<<"\n";//line break

   

   return 0;//end of program

}

6 0
3 years ago
For the best night photographs, you’ll need to have a camera with a shutter speed of about 3 to 30 seconds
Alex_Xolod [135]
What are you trying to ask?

8 0
3 years ago
How to determine the critical crack size for a<br> plate
Blababa [14]
Wait what? is that really a question orr
7 0
3 years ago
Need help on k12 homework
Natalija [7]
Trying you're best and show you're work
7 0
3 years ago
Read 2 more answers
Other questions:
  • Help?!<br> Does anyone know how to use Adobe SoundBooth?
    14·2 answers
  • K
    15·2 answers
  • A collection of computers and other hardware devices that are connected together to share hardware, software, and data, as well
    15·1 answer
  • A technician receives an invalid certificate error when visiting a website with port 443 enabled. Other computers on the same LA
    8·1 answer
  • Change the Towers of Hanoi program so that it does the following: a)Counts the number of ring moves and prints that - instead of
    11·1 answer
  • Match the spreadsheet functions to their operations.
    10·1 answer
  • Write a modular program that accepts up to 20 integer test scores in the range of 0 to 100 from the user and stores them in an a
    9·1 answer
  • have a folder on your Windows computer that you would like to share with members of your development team. Users should be able
    9·1 answer
  • What is the name of situation where the same data is stored unnecessarily at different places?
    15·1 answer
  • Tamera was responding to a complaint that one of the employees is having problems with the wired network connection on their lap
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!