Power Algorithm Complexity In Java