Skip to content

Instantly share code, notes, and snippets.

@jamescarr
Created June 3, 2010 18:25
Show Gist options
  • Save jamescarr/424265 to your computer and use it in GitHub Desktop.
Save jamescarr/424265 to your computer and use it in GitHub Desktop.
solving 6
object IsPerfectNumber extends (Int => Boolean) {
def apply(n:Int) = {
if(n % 2 == 0) (1 to n / 2).foldLeft(0)(_+_) == n else false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment