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
Illusion [34]
2 years ago
8

Write a function that takes as input a single integer parameter n and computes the nth Fibonacci Sequence number. The Fibonacci

sequence first two terms are 1 and 1. (so, if n = 2, your function should return 1). From there, the previous two values are summed to come up with the next result in the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, etc.
Computers and Technology
1 answer:
RSB [31]2 years ago
4 0

Answer:

Following are the code to this question:

def Fibonacci(n):#defining a method Fibonacci that accept a parameter

   a = 1#defining a variable a that holds a value 1

   b = 1#defining a variable b that holds a value 1

   if n <= 0:# Use if to check n value

       print("invalid number")#print message

   elif n == 2:#defining elif that check n equal to 2

        return 1#return 1

   else:#defining else block

       print(a)#print value of a

       print(b)#print value of b

       for i in range(2,n):#defining for loop to calculate series

           s = a + b# add value in s variable

           a = b # interchange value

           b = s# hold s value

           print(s)#print s value

Fibonacci(10)#calling method

Output:

1

1

2

3

5

8

13

21

34

55

Explanation:

In the above-given program code, a method "Fibonacci" is defined, which holds a value "n" in its parameter, and inside the method two-variable "a and b" is defined, that holds a value "1".

  • In the next step, if a block is defined that checks n value is less than equal to 0, it will print "invalid number" as a message.
  • In the elif, it checks n value is equal to 2 it will return a value that is 1.
  • In the else block, it will calculate the Fibonacci series and print its value.
You might be interested in
Briefly list four of the basic I/O interface standard? ​
tiny-mole [99]

Four of the basic I/O interface standard are PCI, SCSI, USB and ISA.

<h3>Standard I/O Interface</h3>

Input-Output Interface is used as an method which helps in transferring of information between the internal storage devices. A number of standards have been developed for I/O Interface.

There widely used bus standards are:

  • PCI (Peripheral Component Interconnect)
  • SCSI (Small Computer System Interface), and
  • USB (Universal Serial Bus).
  • ISA (Industry Standard Architecture)

Find out more on Standard I/O Interface at: brainly.com/question/24347579

4 0
2 years ago
Mike needs to write the primary objectives of a project in a project plan. In which section should he write them?
pochemuha
D because you are always supposed to use your schedule
5 0
3 years ago
Water is constantly in motion.<br> True or false
motikmotik

Answer: true

Explanation: yes water is constantly in motion

7 0
2 years ago
Write an algorithm to sum to values
Elis [28]

Answer:

There is no need to make an algorithm for this simple problem. Just add the two numbers by storing in two different variables as follows:

Let a,b be two numbers.

c=a+b;

print(c);

But, if you want to find the sum of more numbers, you can use any loop like for, while or do-while as follows:

Let a be the variable where the input numbers are stored.

while(f==1)

{

printf(“Enter number”);

scanf(“Take number into the variable a”);

sum=sum+a;

printf(“Do you want to enter more numbers? 1 for yes, 0 for no”);

scanf(“Take the input into the variable f”);

}

print(Sum)

Explanation:

hi there answer is given mar me as brainliest

5 0
3 years ago
What is administrator access? Multiple Choice refers to how quickly a system can transform to support environmental changes perf
IrinaVladis [17]

Answer:

Administrator access is:

refers to the varying levels that define what a user can access, view, or perform when operating a system refers to the time frames when the system is operational

Explanation:

The reasons behind this answer are that in the first place the administrator role is the maximum role an account can have in the operating system. Controlling the different levels of access the rest of the accounts can have on the system. It then is a hierarchical role, not the changes someone can execute in a certain environment, these are called rules.

3 0
2 years ago
Other questions:
  • Janet is testing the effectiveness of four different plant foods. She plants four identical seeds in four identical pots, supply
    6·2 answers
  • What is one course of action available in every problem solving process?
    9·2 answers
  • Programa en C
    9·1 answer
  • There are a few simple rules that you can follow to store and manage files and folders in your computer. What is the most import
    9·2 answers
  • How do you get the computer to stop opening randomly
    15·2 answers
  • I have this assignment due TONIGHT BEFORE 10PM! Please help. 50 points for whoever will help!! Here is the assignment.
    7·1 answer
  • Consider the method get Hours, which is intended to calculate the number of hours that a vehicle takes to travel between two mil
    6·1 answer
  • How exactly do you find the circumference by using C++ Programming? I really need a specific answer.
    14·1 answer
  • The phrase ________ refers to data that is inaccurate, incomplete, or erroneous.
    6·2 answers
  • a developer manages an application that interacts with amazon rds. after observing slow performance with read queries, the devel
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!