A homework problem needs me to calculate gcd of 2 numbers. But using the modulo keyword in the function for gcd gives the above error when run on Repl.it (online IDE).
I looked at other answers, but they don't exactly provide a solution to the problem. I tried to run the program using jdoodle.com (another online IDE) and it works perfectly there. So, I don't know why it won't work on Repl.
;; My gcd function
(define (gcd a b)
(cond
[
(= b 0) a
]
[else
(gcd b (modulo a b))
]
)
)
I would like to know why this doesn't work for Repl IDE and if there is any way how I can make it work there without simply switching to another website.
modulo
function is not implemented in BiwaScheme used by repl.it. However good new is - mod
function is! So, with some reasonable reformatting, this should work:
(define (gcd a b)
(cond [(= b 0) a]
[else (gcd b (mod a b))]))