Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14 Recursion - is-even? #159

Closed
zackteo opened this issue Dec 24, 2020 · 1 comment
Closed

14 Recursion - is-even? #159

zackteo opened this issue Dec 24, 2020 · 1 comment

Comments

@zackteo
Copy link

zackteo commented Dec 24, 2020

Is it me or does the currently is-even? function seem wrong?

(defn is-even? [n]
  (if (= n 0)
    __
    (___ (is-even? (dec n)))))

Should it not be ...

(defn is-even? [n]
  (if (= (rem n 2) 0)
    true
    (not (is-even? (dec n)))))
@zackteo
Copy link
Author

zackteo commented Dec 24, 2020

Whoops mistake. I understand why it works already

@zackteo zackteo closed this as completed Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant