Skip to Main Content
Java 6 Illuminated: An Active Learning Approach, 2nd Edition
book

Java 6 Illuminated: An Active Learning Approach, 2nd Edition

by Julie Anderson, Herve J. Franceschi
February 2008
Intermediate to advanced content levelIntermediate to advanced
1288 pages
39h 39m
English
Jones & Bartlett Learning
Content preview from Java 6 Illuminated: An Active Learning Approach, 2nd Edition
13.2 Recursion with a Return Value 947
case argument receives its return value, which allows that method to return
a value to its caller, and so on, until the method is able to return a value to
the initial caller. In this way, the return values unravel up to the initial
caller.
To see how this works, lets look at an example of a recursive method that
returns a value.
13.2.1 Computing the Factorial of a Number
We will define a recursive method to compute and return the factorial of a
positive integer.
The factorial of a positive number is defined as follows:
factorial(n) = n ! = n * (n 1) * (n 2) * (n 3) * ... .* 4 * 3 * 2 * 1
The factorial of
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour
Java Illuminated, 4th Edition

Java Illuminated, 4th Edition

Julie Anderson, Hervé J. Franceschi

Publisher Resources

ISBN: 9780763749637