- or download this
(define (sum-integers a b)
(if (> a b)
0
(+ a (sum-integers (+ a 1) b))))
- or download this
(define (sum-cubes a b)
(if (> a b)
0
(+ (cube a) (sum-cubes (+ a 1) b))))
- or download this
(define (sum term a next b)
(if (> a b)
...
(+ (term a)
(sum term (next a) next b))))
- or download this
(define (inc n) (+ n 1))
(define (sum-cubes a b)
(sum cube a inc b))
- or download this
sub sum_integers {
my ($a, $b) = @_;
...
if ($a > $b) { return(0); }
else { return( &cube($a) + &sum_cubes(($a + 1), $b) ); }
}
- or download this
sub sum {
my ($term, $a, $next, $b) = @_;
...
my ($a, $b) = @_;
return( &sum(&cube, $a, &inc, $b) );
}