I came up with this math script
x=0; x+=Ran#ⁿ, n=0…1000000000
Ran# is a random number generator that returns a uniform random real number from 0 (inclusive) to 1 (exclusive)
ⁿ is to take the random number to the power of n.
n=0…1000000000 means n is changing from 0 to 1000000000. It's equivalent to for(int n=0; n<=1000000000; n++) .
What is the average value of x?
Assuming I'm understanding you correctly, this should be $$\begin{eqnarray*}\int_0^1\sum_{n=0}^{1000000000}x^n\,d x&=&\sum_{n=0}^{1000000000}\int_0^1x^n\,dx\\&=&\sum_{n=0}^{1000000000}\left(\left.\frac{x^{n+1}}{n+1}\right\rvert_0^1\right)\\&=&\sum_{n=0}^{1000000000}\frac{1}{n+1}\\&=&\sum_{n=1}^{1000000001}\frac{1}{n}\end{eqnarray*}$$ which is $H_{1000000001}$, the $1000000001^\text{th}$ Harmonic number.
You can approximate that with $H_n \approx \ln n+\gamma+\frac1{2n}-\frac1{12n^2}$, where $\gamma\approx 0.5772156649$ is the Euler-Mascheroni constant. In this case, that comes out to be about $21.3004815033$.