Use recursion. This is a way to do something in Scheme / Racket. And try never to use set!other functions that change variables, if there is no other choice.
Here is an example of a recursion tutorial in a schema:
(define factorial
(lambda (x)
(if (<= x 1)
1
(* x (factorial (- x 1))))))
source
share