recursion depth problem

proctor 12cc104 at gmail.com
Sun Apr 22 20:03:57 EDT 2007


On Apr 22, 5:51 pm, Michael Bentley <mich... at jedimindworks.com> wrote:
> Oops!  Note to self: *ALWAYS* try code before posting to a public
> forum :-(
>
> def binary(val, width):
>         print '%10s = the sum of' % val
>         for i in [2 ** x for x in range(width - 1, -1, -1)]:
>                 a = val / i
>                 print ' ' * 13 + '%s * (2 ** %s)' % (a, width)
>                 val -= i * a
>                 width -= 1
>
> binary(233, 8)

very cool.  thanks a lot michael.  very interesting.

proctor.




More information about the Python-list mailing list