得到 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;
}
原文地址:https://www.cnblogs.com/wuOverflow/p/4921476.html