Although implemented the code. But I was not clear about the logic. Can you please explain the logic
I Haven't Understood the logic behind the code
@Gunit
Let’s say you need to find x^n
So if n is even if you did x^n/2 * x^n/2 it will be x^(n/2+n/2) which is x^n
If n is odd, let’s say n1 is n-1, then x^n1 ( which can be calculated via above logic ) can be multiplied with x, x^n1 * x = x^(n1+1) = x^n
Base case is n==0 or n==1 for which we return 1 and x correspondingly