Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created May 8, 2021 07:03
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 CheolhoJeon/c8f2978c46ee0fad66533fd7ea8f93db to your computer and use it in GitHub Desktop.
Save CheolhoJeon/c8f2978c46ee0fad66533fd7ea8f93db to your computer and use it in GitHub Desktop.
package chap4.Recursion
import atomictest.eq
fun factorial(n: Long): Long {
if (n <= 1) return 1
return n * factorial(n - 1)
}
fun main() {
factorial(5) eq 120
factorial(17) eq 355687428096000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment