by
51 7
0
4
3,946
0
Top 1% !
Famous
Specified
OpenSource
Popularity: 2313rd place
Created
Modified Oct 20, 2016
No tags for this snippet yet.
Languagepython
LicenseMIT_X11

Long sum

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1501511/Long-sum?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
def classic_sum(a, b, base=10): i, carry = 0, 0 while i < max(len(a), len(b)) or carry: if i == len(a): a += [0] a[i] += int(carry) + b[i] if i < len(b) else 0 carry = a[i] >= base if carry: a[i] -= base i += 1 return a
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus