+ 1
Any degree element(root) from any number
Did exist better, more precise method to calculate any degree element/root from any number. I've tried this: y = lambda x: pow(x[0], 1/x[1]) print(y((64,3))) but this use rounds 1/3 and it cause low precision
1 ответ
+ 1
@Jay Matthews -> its correct only when we expect result is integer. Your solution doesn't work correctly for most options, example:
print(int(2**(1/2)))
print(2**(1/2))
or
print(int(64**(1/3)))
print(64**(1/3))
Only way is to use round function and set precise?
print(round(64**(1/3),3))
Check here: https://code.sololearn.com/c80L6zKB6uAN/#py