We are writing an application that should be able to read command-line arguments and calculate the factorial of a number.
Your task is to implement the getArgs() method, which takes the args array as a parameter and returns the resulting integer from the arguments.
Introduction to kotlinx-cli
Arguments into factorial
Report a typo
Sample Input 1:
--num 10Sample Output 1:
The factorial of 10 is: 3628800Write a program in Kotlin
import kotlinx.cli.*
fun getArgs(args: Array<String>): Int {
// make your code here
return num
}
fun factorial(n: Int): Long {
return if (n == 1) n.toLong() else n * factorial(n - 1)
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.