Recursion PowerPoint PPT Presentation

presentation player overlay
About This Presentation
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