# Class 14: Recursion with Natural Numbers (1)

Back to Recursion with Lists. On to Recursion with Natural Numbers (2).

This outline is also available in PDF.

Held: Monday, 18 September 2006

Summary: Today we consider recursion over a different domain, that of the natural numbers.

Related Pages:

Notes:

• Reminder: CS Extra Tommorrow: Reports from the Field.
• Homework 5 returned. Notes on the homework emailed.
• I'll leave time for questions on homework 6.

Overview:

• Writing Recursive Procedures.
• Short Introduction to Numeric Recursion.
• Lab.

## Writing Recursive Procedures

• There seems to be some confusion on how you write recursive procedures yourself.
• We'll discuss these issues.
• The structure is not in the lab because I'm working on a reading.

## Recursion with Numbers

• While most of the recursion we've been doing has used lists as the structure to recurse over, you can recurse with many different kinds of values.
• It is fairly common to recurse using numbers.
• The natural base cases for integers are when you hit 0 or when you hit 1.
• The natural simplification step for recursive procedure using numbers calls typically involves subtracting 1 from the argument.
• Other simplifications, such as dividing in half, are also possible.

## Lab

Back to Recursion with Lists. On to Recursion with Natural Numbers (2).

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Thu Nov 30 21:43:23 2006.
The source to the document was last modified on Mon Sep 4 08:43:33 2006.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2006F/Outlines/outline.14.html`.

You may wish to validate this document's HTML ; ;

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2006 Samuel A. Rebelsky. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit `http://creativecommons.org/licenses/by-nc/2.5/` or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.