求正整数的阶乘:
def factorical (n : Int) : Int = if (n == 0) 1 else n*factorical (n - 1)
<<输出结果>>:
factorical( n )
求两个整数的最大公约数:
def gcd (a : Int, b: Int) : Int = if (b == 0) a else gcd (b, a%b)
<<输出结果>>:
gcd (a,b)
求正整数的阶乘:
def factorical (n : Int) : Int = if (n == 0) 1 else n*factorical (n - 1)
<<输出结果>>:
factorical( n )
求两个整数的最大公约数:
def gcd (a : Int, b: Int) : Int = if (b == 0) a else gcd (b, a%b)
<<输出结果>>:
gcd (a,b)