Skip to content

Instantly share code, notes, and snippets.

@adilakhter
Created May 18, 2014 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adilakhter/37eacb1cf398af489240 to your computer and use it in GitHub Desktop.
Save adilakhter/37eacb1cf398af489240 to your computer and use it in GitHub Desktop.
def odd1(n: Int): Boolean= {
if (n==0) false
else even1(n-1)
}
def even1(n: Int): Boolean = {
if (n==0) true
else odd1(n-1)
}
// output from scala repl
> even (3) => 3 2 1 0 => false
> even(4) => 4 3 2 1 0 => true
> odd(3) => 3 2 1 0 => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment