Professional Documents
Culture Documents
2. Task to be done/ Which logistics used: To implement the power function with
complexity O(log n).
X^8=x^4 *x^4
X^4=X^2 *x^2
X^2=x *x
x*x^n/2*x^n/2, if n is odd
X^8=x*x*x*x*x*x*x*x
3. Algorithm/Flowchart
Step 1: suppose x and n numbers
Step 2: n mod 2
Step 6: END
if (n == 0)
return 1;
else
int main() {
int x,n;
cout<<"enter the vale of x (base) and n (power):"<<endl;
cin>>x>>n;
return 0;
6. Result/Output/Writing Summary:
Output: