[Tutor] Converting integers into digit sum (Python 3.3.0)

Alan Gauld alan.gauld at btinternet.com
Mon Dec 9 23:47:01 CET 2013


On 09/12/13 22:28, Dave Angel wrote:
> On Mon, 09 Dec 2013 20:27:38 +0000, Alan Gauld
> <alan.gauld at btinternet.com> wrote:
>> Incidentally, I just remembered another completely different
>> way to do it, although I can't recall how it works!

> Unfortunately it doesn't work for 10, 20, ...

Ah, I knew it must be too good to be true :-)

> This is related to a technique called casting out nines (and nine is
> magic because it's one less than the base we work in).

OK, Thanks for the pointer.

I still have no idea how I knew about that technique but it just
appeared, fully formed, in my brain. Bizarro!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list