Answers for "kotlin factorial"

0

kotlin factorial

fun main(args: Array<String>) {

    val num = 10
    var factorial: Long = 1
    for (i in 1..num) {
        // factorial = factorial * i;
        factorial *= i.toLong()
    }
    println("Factorial of $num = $factorial")
}
Posted by: Guest on March-03-2022

Browse Popular Code Answers by Language