Created
June 4, 2016 11:40
-
-
Save codecakes/29a8e633fb05c39137075951bb1c9429 to your computer and use it in GitHub Desktop.
Find the nth root of a Number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
O(1) approximate solution | |
from math import floor, log | |
nth_root = lambda num, n: floor(round(n**(log(num, n) * 1./n), 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment