From: Narayana on
Here is the python snippet to find the divisibility condition for any radix [not limited to binary], for any divisor and for an infinite stream of digits.
http://code.activestate.com/recipes/577326-infinite-stream-divisor/?in=user-4174427

Thanks,
Narayana
From: James Waldby on
On Fri, 23 Jul 2010 11:30:05 -0400, Narayana wrote:
> Here is the python snippet to find the divisibility condition for any
> radix [not limited to binary], for any divisor and for an infinite
> stream of digits.
> http://code.activestate.com/recipes/577326-infinite-stream-divisor/?in=user-4174427

That code worked ok for the handful of finite cases I tried, but always
failed to return when given infinite streams via variations of:

import infStrDiv
def gen():
while (1>0):
yield 1
infStrDiv.infinite_stream_divisor(3,2,gen())

(where your recipe-577326-1.py was saved locally as infStrDiv.py)

Obviously, it doesn't make sense to advertise your function as
working "for an infinite stream of digits". At best you could
say arbitrarily many, or indefinitely many, digits.

One more comment re wording: Your post doesn't pin the phrase
"find the divisibility condition" to any specific action or aim,
ie, leaves its meaning ambiguous.

--
jiw