jak <nos...@please.ty> writes:

[...]

>> --8<---------------cut here---------------start------------->8---
>> def powers_of_2_in(n):
>>    if remainder(n, 2) != 0:
>>      return 0, n
>>    else:
>>      s, r = powers_of_2_in(n // 2)
>>      return 1 + s, r
>> --8<---------------cut here---------------end--------------->8---
>
> for n = 0 your function get stack overflow

That's right.  Let's say ``assert n > 0'' before we say ``if''.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to