得到 1 + 22 + 333 + 4444 + ... + nnn..n 的和
int foo(int n)
{
if (n < 1){
return 0;
}
int result = 0;
for(int i = 1, factor = 1; i <= n; (factor += (pow(10.0, i))), ++i){
result += (i * factor);
}
return result;
}