Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def isEven(a):
- return (a & 0x1) == 0
- def intPow(val, exp):
- if exp == 0:
- return 1;
- if isEven(exp):
- return intPow(val * val, exp / 2)
- return val * intPow(val * val, (exp - 1) / 2)
- def factorial(val):
- if (val <= 0):
- return 1
- return factorial(val-1)*val
- maxIterations = 150
- def lnCustom(x):
- if (x == 1):
- return 0
- x = float(x)
- result = 0
- for n in range(1, maxIterations):
- curVal = intPow((x-1)/x, n) / n
- result += curVal
- return result
- def eCustom(x):
- x = float(x)
- result = 0
- for n in range(0, maxIterations):
- curVal = intPow(x, n)/factorial(n)
- result += curVal
- return result
- def fracPow(x, exp):
- return eCustom(lnCustom(x)*exp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement