Created
May 8, 2021 07:26
-
-
Save CheolhoJeon/195fede4e530a7957c32e7f2d8d3814e to your computer and use it in GitHub Desktop.
This file contains 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
package chap4.Recursion.iteration | |
import atomictest.eq | |
fun sum(n: Long): Long { | |
var accumulator = 0L | |
for (i in 1..n) { | |
accumulator += i | |
} | |
return accumulator | |
} | |
fun main() { | |
sum(10000) eq 50005000 | |
sum(100000) eq 5000050000 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment