Update binary_exponentiation.py

This commit is contained in:
marina 2023-08-07 17:05:08 -07:00 committed by GitHub
parent d61684057c
commit e1e46e59c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,11 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# author: bt3gl # author: bt3gl
``` '''
Binary exponentiation, also known as exponentiation by squaring, is a technique for Binary exponentiation, also known as exponentiation by squaring, is a technique for
efficiently computing the power of a number. By repeatedly squaring x and halving n, efficiently computing the power of a number. By repeatedly squaring x and halving n,
we can quickly compute x^n using a logarithmic number of multiplications. we can quickly compute x^n using a logarithmic number of multiplications.
```` '''
def binary_exp(x: float, n: int) -> float: def binary_exp(x: float, n: int) -> float: