Flashcards
Pow(x, n)
Cards in this deck (1)
- 1Input: 2.00000, 10 Output: 1024.00000 Input: 2.10000, 3 Output: 9.26100class Solution {
public double myPow(double x, int n) {
if(n == 0 ) return 1;
double temp = myPow(x,n/2);
if(n % 2 == 0 ) return temp * temp;
else{
if( n > 0 ){
return x*temp*temp;
}else
return (temp*temp)/x;
}
}
}
Information
- Description
- Flashcards on Pow(x, n), created by Suhas S on 23/03/2018.
- Created by
- Suhas S · Mar 2018
- Updated
- Jun 4, 2018
- Views
- 0
- Rating