I won't go into details but the main idea goes like this: let's say you have 5192/7. You can write 5192 as 5000+100+90+2 but you can also do it like this: 7(555)+7(11)+7(9)+2 but you that's obviously less than 5192 so you can add respective complements 1115 23 27 (finding them is trivial). 1115 = 7(111)+223+7(11)+23+7(1)+5 and so on

mcz@mcz@mastodon.sdf.orgThe algorithm is optimized for cases when divisor is equal to base minus one

hehehe