macro-program code

Hello!
Please, how to write program code for macro recognising sequence of numbers like:

abcde

a,b,c,and d are any possible numbers(1-9)
e=a+b+c+d

Like:
10203
31217 etc

Many thanks!

If a=b=c=d=9 then c=36 and abcde=999936 or c=6 and abcde=99996?