Scheme Harmonic Function
Is there a way to write this function using an if statement instead of
cond? The following works as intended, but I was curious to see another
option.
(define (harmonic-numbers n)
(cond ((= n 1) 1)
((> n 1) (+ (/ 1 n)
(harmonic-numbers(- n 1))))))
No comments:
Post a Comment