pow in logn time