Skip to content

Instantly share code, notes, and snippets.

@JorgeCastilloPrz
Last active May 12, 2017 14:25
Show Gist options
  • Save JorgeCastilloPrz/2e0dabdd4ff293f58ef784421b2c42aa to your computer and use it in GitHub Desktop.
Save JorgeCastilloPrz/2e0dabdd4ff293f58ef784421b2c42aa to your computer and use it in GitHub Desktop.
factorcalculatorpure.kt
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