题解 | #数列求和#

数列求和

http://www.nowcoder.com/practice/6893484c04c24bfca1f606b1823a468d

public class Main { public static void main(String[] args) {

    //write your code here........
    long sum = 0L;
    long temp = 0L;
    for(int i = 1;i <= 10;i++){
        //先求数列
        temp = temp * 10 + 9;
        //后求和
        sum = sum + temp;
    }
    System.out.print(sum);
}

}

全部评论

相关推荐

程序员饺子:正常 我沟通了200多个 15个要简历 面试2个 全投的成都的小厂。很多看我是27直接不会了😅
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务