12.07.2015 Views

CSCE 314 Programming Languages - TAMU Computer Science ...

CSCE 314 Programming Languages - TAMU Computer Science ...

CSCE 314 Programming Languages - TAMU Computer Science ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Recursive FunctionsFunctions can also be defined in terms ofthemselves. Such functions are called recursive.factorial 0 = 1factorial n = n * factorial (n-1)factorial 3 = 3 * factorial 2= 3 * (2 * factorial 1)====3 * (2 * (1 * factorial 0))3 * (2 * (1 * 1))3 * (2 * 1)3 * 2factorial maps 0 to 1,and any otherpositive integer tothe product of itselfand the factorial ofits predecessor.= 636

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!