Posts

Showing posts with the label computed an exponential by iteratively executing successive multiplication

Exponentiation algorithm

Image
In programming there are not just 1 method to solve the problems for the exponential algorithm.What is exponential algorithm? Well is also can be mention as power. For example 2 to the power of 3 is 8 (2^3=8). Exponential algorithm is to find the value through computational way. You can computed an exponential by iterative. For example (in python): def iterPower(base, exp):     result=base     if exp==0:         return 1     else:         while exp>1:             result*=base             exp-=1         return result The code is like keep multiple the base number while minus the exponential value until the exp is 0.Is like 5^5=5*5*5*5*5 Above is an exponential by iteratively executing successive multiplications. Exponential can be computed in a recursive function. def recurPower(base, exp):     if exp==0: ...