Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(x: Float): Float = {
- def factorial(x: Int): Int = if (x <= 1) 1 else x * factorial(x - 1)
- def compute_exp(x: Float, count: Int = 9): Float = {
- if (count <= 1) x
- else (Math.pow(x, count) / factorial(count)).toFloat + compute_exp(x, count - 1)
- }
- compute_exp(x)+1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement