Recursion - PowerPoint PPT Presentation

About This Presentation
Title:

Recursion

Description:

A Scheme program to compute factorials is (define (fact x) if (= x 0) 1 (* x (fact (- x 1)))) Also recursive. Here is one to do powers. X^N (define (power x n) ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 3
Provided by: unca1
Category:
Tags: fact | recursion

less

Transcript and Presenter's Notes

Title: Recursion


1
Recursion
  • A Scheme program to compute factorials is?
  • (define (fact x)
  • if ( x 0)
  • 1
  • ( x (fact (- x 1))))

2
Also recursive
  • Here is one to do powers?
  • XN
  • (define (power x n)
  • (if ( n 0)
  • 1
  • ( x (power x (- n 1)))))
Write a Comment
User Comments (0)
About PowerShow.com