I tried to find the value of n using the below code, but it returns None. Where am I going wrong?
from math import log2
def f(n):
y = 3600*987
a = int(1560878*log2(n))
for i in range(a):
if n==1:
n = y/a
return(n)
else:
print(x)
print(f(1))
CodePudding user response:
If you pass 1
as argument a
becomes 0 so you for loop doesn't run
CodePudding user response:
This is occurring because a
evaluates to 0, so for i in range(a):
does not get executed, causing the function to not return anything.
logbase2(1) = 0, which is why a
evaluates to 0.