Sum of number's digits I'm looking for a math function that taking an integer returns the sum of it's digits. I tried with this method:
-I've got a digit sequence $d_{k+1},d_{k},...,d_{1}$ with $d_{k+1}\ne 0$ and $d_i \in \{0,1,2 \dots , 9\}$ for all $1 \le i \le k+1$; this represents the number $A$ in base $10$, so: $$A = \sum_{i = 1}^{k+1} d_i 10^{i-1}$$
-Now I know that each digit is generated by: $$d_i = \sum_{i=1}^{\left \lfloor \log_{10}(A)+1 \right \rfloor}\frac{A\,\, \pmod{10^i}-A\,\, \pmod{10^{i-1}}
}{10^{i-1}}$$
-I expand the sum and I obtain: $$\frac{A\, \pmod{10}-A\,\,  \pmod1}{1}+\frac{A\, \pmod{10^2}-A\,\,  \pmod{10}}{10}+\cdots +\frac{A\, \pmod{  10^i}-A\pmod{10^{i-1}}}{10^{i-1}}$$
-I have to simplify the denominator so: $$\frac{1\cdot (A\, \pmod{10}-A\,\,  \pmod1)}{1}+\frac{10\cdot (\lfloor\frac{A}{10}\rfloor\, \pmod{10}-\lfloor\frac{A}{10}\rfloor\,\,  \pmod  1)}{10}+\cdots +\frac{10^{i-1}\cdot (\lfloor{\frac{A}{10^{i-1}}}\rfloor\, \pmod{10}-\lfloor\frac{A}{10^{i-1}}\rfloor\,\,  \pmod  1)}{10^{i-1}}$$
-I split the term: $$A\, \, \pmod{10}+\lfloor\frac{A}{10}\rfloor\, \, \pmod{10}+\cdots+\lfloor\frac{A}{10^{i-1}}\rfloor\, \, \pmod{10}-(A\, \, \pmod1+\lfloor\frac{A}{10}\rfloor\, \, \pmod1+\cdots +\lfloor\frac{A}{10^{i-1}}\rfloor\, \, \pmod1)$$
-Now I would have picked up $\pmod{10}$ and $\pmod1$: $$\left (\sum_{i=1}^{\left \lfloor \log_{10}(A)+1 \right \rfloor}\lfloor\frac{A}{10^{i-1}}\rfloor\right)\, \, \pmod{10}-\left (\sum_{i=1}^{\left \lfloor \log_{10}(A)+1 \right \rfloor}\lfloor\frac{A}{10^{i-1}}\rfloor\right)\, \, \pmod1$$; but I can't. Any ideas to move forward?
Thanks
 A: Here's a "formula" for the sum of the digits of $n$:
$$s(n) = \sum_{k=0}^{\lfloor\log_{10} n\rfloor}\left(\left\lfloor\frac{n}{10^k}\right\rfloor-10\left\lfloor\frac{n}{10^{k+1}}\right\rfloor\right)$$
Note that each summand gives you a digit. 
This can be simplified to $$s(n)= n - 9 \sum_{k=1}^{\lfloor\log_{10} n\rfloor}\left\lfloor\frac{n}{10^k}\right\rfloor$$
Note however that the term "formula" is not precisely defined. It's a term that depends of the context. It can mean very different things depending of the field you're working.
I think that in number theory or combinatorics one would allow the use of the floor and log functions, so one would consider this a formula (although not a "closed" formula, because the number of operations is not bounded)
A: I know this is a strange idea, and not an answer to the question, but it's possible that you can do something useful by reversing the task. 
That is to say, instead of starting with $n$, you can say "I've got a digit sequence $d_k, d_{k-1}, \ldots, d_0$, with $d_k \ne 0$, and $0 \le d_i \le 9$ for all $i$, and this represents the number $n$ in base $10$," so that
$$
n = \sum_{i = 0}^k d_k 10^k.
$$
Now you can do things like talk about $\log_{10} n$ (which is between $k$ and $k+1$, and is approximately $k + \log d_k$, for instance), and other functions of $n$ may similarly be expressible in terms of the $d_i$. 
Of course, without knowing details --- "I want to find a math formula that I will use to solve some problems, related with digits sum..." is a little bit vague --- it's tough to know whether this approach could be of any use.
Post-comment addition
Here's a little matlab program that solves your problem (for not-too-large cases) using the approach I described:
function s = digitpower(k, a)
% Find numbers containing k or fewer digits with the property that the
% number equals v^a, where v is the sum of the digits of the number.

if (k == 0) 
    s = [];
end

trials = digits(k); % the first 10^k numbers, as digit sequences. 
powervec = 10.^((k-1):-1:0);
nums = powervec * trials;
sums = sum(trials, 1); 
pows = sums .^ a; 
s = find (nums == pows);
s = nums(s);

To make that run, you also need the "digits" program:
function s = digits(k)
% produce all digit-sequences of length k, in a k x 10^k matrix,
% where each column represents a digit-sequence. 
if k < 1
    error( "Can't get digit sequences of 0-digit numbers");
end

if k == 1
    s = 0:9;
    return;
end

q = digits(k-1);
r = size(q, 1); 
c = size(q, 2); 
qp = repmat(q, 1, 10); 
h = repmat((0:9)', 1, c)';
h = reshape(h, 1, []);
s = [h;qp];

Some sample executions of the program look like this:
>> digitpower(2, 1)

ans =     0     1     2     3     4     5     6     7     8     9

>> digitpower(2, 2)

ans =
     0     1    81

>> digitpower(2, 3)

ans =     0     1

>> digitpower(3, 3)

ans =     0     1   512

>> digitpower(4, 3)

ans =           0           1         512        4913        5832

THe first one says that the only numbers with 0, 1, or 2 digits whose digit-sum, to the first power, is equal to the number itself, are the numbers 0 through 9. 
The second says that among 0-2-digit numbers, those whose digit-sum, squared, equal the number are 0, 1, and 81. 
The last says that among numbers of no more than 4 digits, those that equal the cube of their digit-sum are 0, 1, 512, 4913, and 5832.
Those last ones surprised me a bit -- I didn't really expect to see as many positive results as this. 
A: I worked on similar idea in my question many years ago. I asked to find any digit in a given number. There is an answer  for my question to find any digit of a number via Fourier series expansion. Please check @Zander 's answer how to find the function. We can use it to find the sum of digit's numbers eaisly as shown below.
Let's define   $d_n(A)$ is digit number of A,
Where A is a real number.
For example:  
$d_3(2345.67)=2$
$d_0(2345.67)=5$ 
$d_{-1}(2345.67)=6$ 
We can write easily
$d_n(A) = d_0(10^{-n}A)$ and 
$$A = \sum_{k=-\infty}^\infty 10^k d_k(A)$$
$$A = \sum_{k=-\infty}^\infty 10^k d_0(10^{-k}A)$$
If you notice the formulas above , it is enough to find out only $d_0(A)$.
If we find $d_0(A)$ ,any digit can be found by using it. 
$$
d_0(A) =\frac{9}{2} -\frac{10}{\pi}\sum_{k=1}^\infty b_k \sin\left(\frac{k\pi A}{5}\right)
$$
where
$$
b_k = \begin{cases}0 & \mathrm{if}~10\mid k\\ 1/k & \mathrm{otherwise}\end{cases}
$$
Thus we can write the sum of integer number's digits :$T$
If A is a positive integer , you can write $T$ as
$$ T=\sum_{k=0}^\infty d_0(10^{-k}A)$$
A: If you allow the greatest integer function (whose domain is the set of reals and whose range is the set of integers) and the "mod $10$" function (whose domain is the set of integers and whose range is the set of residues from $0$ to $9$), then, for positive integers $A$, we have
$$S(A)=\sum_{n=0}^\infty\left(\left\lfloor A\over10^n\right\rfloor\mod10 \right)$$
or, written somewhat more abstractly, with obvious interprets of the symbols,
$$S(A)=\sum_{n=0}^\infty m_{10}(g(A/10^n))$$
E.g.,
$$\begin{align}
S(1234)
&=(\lfloor1234\rfloor\mod10)+(\lfloor123.4\rfloor\mod10)+(\lfloor12.34\rfloor\mod10)+(\lfloor1.234\rfloor\mod10)+\cdots\\
&=(1234\mod10)+(123\mod10)+(12\mod10)+(1\mod10)+(0\mod10)+\cdots\\
&=4+3+2+1+0+0+0+0+\cdots\\
&=10
\end{align}$$
Note, the upper limit $\infty$ in the sum can be replaced with something finite but depending on $A$. The "obvious" replacement is $\lfloor\log_{10}A\rfloor$, but the "easiest" is simply $A$ itself.
In a (deleted) answer/comment, the OP remarked they were interested in finding a number that is a power of the sum of its digits, i.e., $A=S(A)^k$ for some $k\ge1$.  The first nontrivial example (with $A\ge10$) is $A=81$, and after that come $A=512$ and $A=2401$.  The sequence can be found at https://oeis.org/A023106 .
