Starting Out with Python (3rd Edition)
Starting Out with Python (3rd Edition)
3rd Edition
ISBN: 9780133582734
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 12, Problem 2SA

In this chapter, the rules given for calculating the factorial of a number are as follows:

If n = 0 then factorial (n) = 1

If n . 0 then factorial (n) = n × factorial (n - 1)

If you were designing a function from these rules, what would the base case be? What would the recursive case be?

Blurred answer
Students have asked these similar questions
In this chapter, the rules given for calculating the factorial of a number are as follows:If n = 0 then factorial(n) = 1If n . 0 then factorial(n) = n × factorial(n – 1)If you were designing a function from these rules, what would the base case be? What wouldthe recursive case be?
Each of the following recursive function definitions contains an error.  Briefly but fully and clearly explain what is wrong with each definition.   f(x) = 3*f(x-5)                              where x is a positive integer.          f(0) = 7      2. g(x) = 2 - 4*g(x)                          where x is a positive integer.        g(1) = 3        g(2) = 4
The following recursive function takes three positive integer arguments:  def compute(n,x,y) :     if n==0 : return x     return compute(n-1,x+y,y)   What is the value returned by the compute function? n*x+y x+y x+n*y x What if: will the returned value be for the compute function defined in the question above if the argument n is negative? x x-n*y x+n*y The function will never return a value.

Chapter 12 Solutions

Starting Out with Python (3rd Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
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
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License