There are several problems. One is that the parenthesis are wrong around the inner-if
such that it has no true-expr or false-expr within the form. The parenthesis around false later on are also problematic. In addition, every if
should have both true-expr and false-expr supplied (although this differs in dialects, IIRC).
The symmetric structure can be seen in a corrected expanded form.
(if (divisible2? n) ; outer if-expr
(if (divisible3? n) ; outer then-expr (and inner if-expr)
#t ; inner then-expr
#f) ; inner else-expr
#f) ; outer else-expr
Alternatively, simply use and
.
(and (divisible2? n) (divisible3? n))
And you could make the divisible?
functions take in the "divisible by" value.