b = int(input("Enter 2nd num \n"))
i = 1
while True:
d = a/b
e = d
f = e/b
i = 1
if f == 1:
break
print(f"Exponent xyzz: {i}")
For example of I give 64 as A and 4 as B, it shall return 3......, like that. Please help. There is some bug in this code.
CodePudding user response:
def myLog(x, b):
if x < b:
return 0
return 1 myLog(x/b, b)
refer to:
Get logarithm without math log python
CodePudding user response:
In your code, you are not taking user input for 1st num, so that is first bug. Secondly a and b are constants, so d value is always same everytime the loop is executed and the loop will never break. We have to update A so that A becomes 1 while multiple division and the loop terminates. You can try doing this:
a=int(input("Enter 1st num \n"))
b = int(input("Enter 2nd num \n"))
i = 0
while True:
a = a/b
i = 1
if a == 1:
break
print(f"Exponent xyzz: {i}")
Well check the indentation because I've copied and pasted it here since I was not able to upload image