# Sum of the digits of a number non-recursively

Hi, I’m having trouble trying to get this working.
I have a setup like this:

``````       A       B        C
------------------------------
1 |  1234   |  12   |  1234
``````

I want to sum the digits of A1 (10), then the digits of B1 (3) and then the digits of C1 (10), and them add them together. Where I am stuck is trying to add the digits together, because all of the methods that I’ve found are recursive and for A1 I would get 1 instead of 10. How can I get the sum of the digits of the number in each cell non-recursively?

One way to get the sum of digits in e.g. A1
`=SUMPRODUCT(VALUE(MID(A1;ROW(INDIRECT("z1:z"&LEN(A1)));1)))`

1 Like

the aggregated Sum of digits from the range A1:C1

``````=SUMPRODUCT(IFERROR(VALUE(MID(TEXTJOIN("";1;A1:C1);ROW(1:10000);1));0))
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.893562,"math_prob":0.93638575,"size":489,"snap":"2022-40-2023-06","text_gpt3_token_len":131,"char_repetition_ratio":0.21237114,"word_repetition_ratio":0.0,"special_character_ratio":0.35378322,"punctuation_ratio":0.083333336,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9990355,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-27T11:29:17Z\",\"WARC-Record-ID\":\"<urn:uuid:08881b21-d336-4b14-8aef-ec3232503d29>\",\"Content-Length\":\"18716\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c8ff41ee-2c1f-4a40-a4b4-e94c693884e4>\",\"WARC-Concurrent-To\":\"<urn:uuid:b02ff66a-b0af-4920-943a-6a711a9366c2>\",\"WARC-IP-Address\":\"65.109.107.234\",\"WARC-Target-URI\":\"https://ask.libreoffice.org/t/sum-of-the-digits-of-a-number-non-recursively/68043\",\"WARC-Payload-Digest\":\"sha1:MLUM7KGBOEFYIKMBAWUWQIGDSQOTXZTL\",\"WARC-Block-Digest\":\"sha1:DSMFQDKHRZN2S7XV7QR3NU4U6V43RJKC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764494976.72_warc_CC-MAIN-20230127101040-20230127131040-00223.warc.gz\"}"}