Advertisement
gmendezm

Fibonacci y Factorial

Mar 24th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.28 KB | None | 0 0
  1. (define (factorial n)
  2.   (cond
  3.     ((= n 0) 1)
  4.     (else
  5.      (* n (factorial (- n 1)))
  6.     )
  7.    )
  8. )
  9.  
  10. ;(factorial 6)
  11.  
  12. (define (fibonacci n)
  13.   (cond
  14.     ((= n 0) 0)
  15.     ((= n 1) 1)
  16.     (else
  17.      (+ (fibonacci (- n 1)) (fibonacci (- n 2)))
  18.     )
  19.   )
  20. )
  21.  
  22. (fibonacci 17)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement