int power (int a, int b) {
if (b==0)
return 1;
if (b==1)
return a;
int ans = power(a,b/2);
if (b%2==0)
return ans*ans;
else
return a*ans*ans;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter