Skip to content

Instantly share code, notes, and snippets.

@codecakes
Created June 4, 2016 11:40
Show Gist options
  • Save codecakes/29a8e633fb05c39137075951bb1c9429 to your computer and use it in GitHub Desktop.
Save codecakes/29a8e633fb05c39137075951bb1c9429 to your computer and use it in GitHub Desktop.
Find the nth root of a Number
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