This is absolutely driving me nuts. The supposed simplest thing I can imagine and I can’t do it.
I just want to computer factorial inputting an int and output a real.
I’ve tried to coerce in numerous way.
fun factorial 0 = 1 |
factorial n = n * factorial(n-1);
To convert an int to a real, you use
Real.fromInt. If you want to return reals, you should also return1.0instead of1as the base case. So your code becomes: