math - Mathematical root of any two numbers in PHP -


i'm trying create simple advanced calculator fun , i'm facing problem. in php have function sqrt() let's calculate square root of number. thing want achieve make calculator count given root of given number. example if user enters "5 7" calculator supposed calculate not square 7th root of number 5. idea how achieve this? sorry if misunderstood something, i'm not expert in english math. in advance.

using pow:

function nthroot($number, $nthroot) {     return pow($number, (1/$nthroot)); } 

so, nthroot(32, 5) == 2, power of (1/n) same taking nth root of number. e.g.,

  • sqrt(4) == 4^(1/2),
  • sqrt(sqrt(16)) == 16^(1/4), sqrt(sqrt((n)) same saying the square root of square root, i.e., "the 4th root".

Comments