So, we need to that in a way recursion does it. Otherwise, it's a simple O(n) algorithm. We want to do that in O(log n). Like this.

```java
int expo(int a, int b){
  int result = 1; // identity matrix

  while (b){
    if (b%2==1){
      result *= a;
    }
    b /= 2;
    a *= a;
  }

  return result;
}
```