Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
Question
Book Icon
Chapter 13, Problem 2PE
Program Plan Intro

Fibonacci

Program plan:

  • Define a class named “FibCounter()”.
    • Define a method “_init_()”.
      • Set the count instance variable to “0”.
    • Define a function “getCount()”.
      • Return the value of instance variable.
    • Define a function “fib()”.
      • Increment the value of instance variable by “1”.
      • If the condition is true,
        • Return “1”.
          • If the condition is not true.
            • Return the sum of “self.fib(n-1)” and “self.fib(n-2)”.
    • Define a function “resetCount(self)”.
      • Set the count instance to “0”
  • Call the function “FibCounter()”.
  • Call a function “fib()”.
  • Print the values.

Blurred answer
Students have asked these similar questions
Using R language
using r language
using r language
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning