LARGESUM

=LARGESUM(a,b)

a
string of digits
b
string of digits

sums 2 large numbers

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
860
Office Version
  1. 365
Platform
  1. Windows
LARGESUM sums 2 large numbers
On Fibonacci post this site was pointed to me Lambda for large numbers . This is my take using recursion. Uses this tools:
T_2RH(a,b)=LAMBDA(a,b,LET(ca,COLUMNS(a),cb,COLUMNS(b),c,ca+cb,s,SEQUENCE(,c),rs,IF(s<=ca,IF(a="","",a),INDEX(IF(b="","",b),s-ca)),rs))
!! recursive !! T_LSUM(a,i)=LAMBDA(a,i,LET(n,COLUMNS(a),x,INDEX(a,n),c,SEQUENCE(,COLUMNS(i)),y,T_2RH(x+INT(INDEX(i,1)/10),i),IF(n=1,INDEX(y,c),T_LSUM(INDEX(a,SEQUENCE(,n-1)),y))))
Excel Formula:
=LAMBDA(a,b,
    LET(ab,CHOOSE({1;2},a,b),l,LEN(ab),ml,MAX(l),x,IF(LEN(ab)<ml,REPLACE(ab,1,0,REPT(0,ml-LEN(ab))),ab),
       mx,--MID(x,SEQUENCE(,ml),1),y,MMULT({1,1},mx),t,T_LSUM(y,0),
       INDEX(t,1)&CONCAT(RIGHT(INDEX(t,SEQUENCE(,ml-1,2)),1))
    )
)
LAMBDA 6.0.xlsx
ABCDEFGHIJKL
1FIB12345678910
2111235813213455
32891442333776109871597258441816765
431094617711286574636875025121393196418317811514229832040
541346269217830935245785702887922746514930352241578173908816963245986102334155
651655801412679142964334944377014087331134903170183631190329712150734807526976777874204912586269025
76203650110743295128009953316291173862675712721395838624452258514337173654352961625912867298799567220260411548008755920
872504730781961405273953788165574703198421061020985772317167680177565277778900352884494557021285372723460248141117669030460994190392490709135
98308061521170129498454011879264806515533049393130496954492866021114850779780503416454622906710552793970088476089443943237914601447233402467620023416728348467700
10excel sum fails
118308061521170129498454011879264806515533049393130496954492865721114850779780503416454622906707552793970088475789443943237914641447233402467622123416728348467685
129378890623731439066130579072161159199194853094755497160500643816367088259695496911122585420196140727489673679891637638612258110008777836610193117799794160047141892880067194370816120
1310466004661037553030975401138047463464291220016041512187673819740274219868223167319404346349900999055168070885485832307283621143489848422977135301852344706746049218922995834555169026354224848179261915075
1411573147844013817084101927372692193078999176150052053620689608327724278932283999750824533928413764606871165730635630699300684624818310284720757613717413913166410277506205636620962692574850823428107600943566776258854844738105
1512704925247670891258141141140593010259439705522191845518257930330963663332986111268189770669185524831629526120101632848857817740794309872302034371264937032042997393488322204671111147398462369175933116481435169820171800815358359254990966640871840
161386700073985079486580519211402836665349891529892376122698374052006863956975682367267407055057792558994435942511475751264321287512596151855463018422468774568155576970220531065681649693251728825683549488150424261407305795904080553832073954659034621587630041982498215
17
18
19LEN
201007987623457654123456787654234512340987345612345987651234523451234587650987653456787654345678765434567
211009088776876651234453436465475476576588585758757555412365098785650987665544332312465189081893873262367
22=LARGESUM(D20,D21)17076400334305357910224119709988917575931371103543063599622236885575316531985769252843427572638696934
23
LARGESUM post
Cell Formulas
RangeFormula
B1:K1B1=SEQUENCE(,10)
A2:A9A2=SEQUENCE(8)
D2:K9D2=B2+C2
B3:B9B3=J2+K2
C3:C9C3=B3+K2
E11:K11,D12:K16E11=LARGESUM(C11,D11)
B12:B16B12=LARGESUM(J11,K11)
C12:C16C12=LARGESUM(B12,K11)
C20:C21C20=LEN(D20)
C22C22=FORMULATEXT(D22)
D22D22=LARGESUM(D20,D21)
Dynamic array formulas.
 
Upvote 0
Checking latest excel update recursion limits on a different type of recursive function.
Before the nr. of digits limit was 100, now is 255.
CM Lambda helper functions.xlsx
ABC
1nr chars:
2255
3
4=REPT("1",A2)111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
5
6=REPT("9",A2)999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
7
8lenghts check=LARGESUM(C4,C6)
92561111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110
10=LEN(C9)
11
12nr chars:
13256
14
15=REPT("1",A13)1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
16
17=REPT("9",A13)9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
18
19=LARGESUM(C15,C17)
20#VALUE!
21
22nr chars:
23255
24
25=REPT("9",A23)999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
26
27=REPT("8",A23)888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
28
29lenghts check=LARGESUM(C25,C27)
302561888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888887
31=LEN(C30)
32
33last 2 digit checkNote:
34to prove the sumTo "hack" excel displaying numbers with so many digits, these are the string representations of the respective numbers.
35is correct
36=RIGHT(C9,2)
3710
38=RIGHT(C30,2)
3987
40
LARGESUM
Cell Formulas
RangeFormula
A4,A27,A25,A17,A15,A6A4=FORMULATEXT(C4)
C4,C15C4=REPT("1",A2)
C6,C17C6=REPT("9",A2)
C8,A36,A38,C29,C19C8=FORMULATEXT(C9)
C9,C30,C20C9=LARGESUM(C4,C6)
A9,A30A9=LEN(C9)
A10,A31A10=FORMULATEXT(A9)
C25C25=REPT("9",A23)
C27C27=REPT("8",A23)
A37A37=RIGHT(C9,2)
A39A39=RIGHT(C30,2)
 

Forum statistics

Threads
1,223,346
Messages
6,171,566
Members
452,410
Latest member
memote1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top