Last active
May 12, 2017 14:25
-
-
Save JorgeCastilloPrz/2e0dabdd4ff293f58ef784421b2c42aa to your computer and use it in GitHub Desktop.
factorcalculatorpure.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sumOfFactors(number: Int) = factorsOf(number).sum() | |
fun factorsOf(number: Int) = (1 to number).toList().filter { isFactor(number, it) } | |
fun isFactor(number: Int, potential: Int) = number % potential == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment