0
votes

Below code gives me error of Multiple markers at this line - recursive value factWithTailRec needs type - Implicit conversions found: i => int2bigIn

@tailrec
 val factWithTailRec = (i:Int, acc:BigInt) =>   if(i == 0) 1  else factWithTailRec(i-1, i * acc)


Could please suggest how can I prevent it. Requirement is to assign val to a recursive function

1

1 Answers

5
votes

As the error says:

Multiple markers at this line - recursive value factWithTailRec needs type - Implicit conversions found: i => int2bigIn

In other words, you need to add a type signature to the val:

val factWithTailRec: (Int, BigInt) => BigInt = (i:Int, acc:BigInt) =>   if(i == 0) 1  else factWithTailRec(i-1, i * acc)