何を渡しても、”hello” と答える(値を返す)関数
def hel(x:Any):String = { "hello" }
// または
def hel(x:Any) = "hello"
渡した数の3乗を計算する関数 cube
def cube(n:BigInt) = n*n*n
2つの数の積を返す関数 mul
def mul(n:BigInt,m:BigInt) = n*m
n の m乗(べき乗)を計算する、再帰的な関数 pow を math.pow を使わずに、乗算の演算子だけで。
def pow(n:BigInt,m:Int):BigInt =
if(m<=0) 1
else pow(n,m-1) * n