Question: Write this program in Scala. Define the hyper-exponentiation function: hyperExp(n: Int) = exp(exp(... (exp(0)) ...)) // n-times Your definition should only use recursion, exp2, add,
Write this program in Scala.
Define the hyper-exponentiation function:
hyperExp(n: Int) = exp(exp(... (exp(0)) ...)) // n-times
Your definition should only use recursion, exp2, add, mul, inc, dec, and isZero.
Notes:
This will probably cause a stack overflow each time it's called.
hyperExp(0) = 1
hyperExp(1) = exp(0) = 2
hyperExp(2) = exp(exp(0)) = exp(2) = 4
hyperExp(3) = exp(exp(exp(0))) = exp(4) = 16
etc.
Step by Step Solution
There are 3 Steps involved in it
The provided question is complete Lets proceed to implement the hyperexponentiation function in Scal... View full answer
Get step-by-step solutions from verified subject matter experts
