finding nth root of a number by using divide and conquer method
I need help on how to get nth root of some number. User enters number n and number he wants root of. I need to solve this without cmath lib and with divide and conquer method. Here's my code that doesn't work yet: #include<iostream> using namespace std; float pow(float a,float c){ if (a == 0) return 0; else if(a == 1) return 1; else{ float p = pow(a,(c/2)); if(c%2) return p*p*a; else return p*p; } } int main(){ float a,b; float c; cout << "Enter positive number:(base)" << endl; do{ cin >> a; }while (a < 0); cout << "Enter number: (root)" << endl; cin >> b; c = 1/b; cout << "Result:"<<pow(a,c)