题解 | #数列求和#

数列求和

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

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

        //write your code here........
        long sum = 0;
        long num = 0;
        for(int i = 0; i < 10; i++){
            num += 9 * Math.pow(10,i);
            sum += num;
        }
        System.out.println(sum);
    }
}
全部评论
Math.pow()返回的是double类型数据,是不是最后需要个强转?
点赞 回复 分享
发布于 2023-06-17 16:03 江西

相关推荐

牛客刘北:如果暑期实习是27届的话,你要晚一年才会毕业,企业为什么会等你呢?要搞清时间逻辑呀!27届现在实习只能是在暑假实习,这是日常实习,不是暑期实习。所以多去投日常实习吧,暑期实习肯定不会要你的
点赞 评论 收藏
分享
07-08 21:30
已编辑
南昌大学 嵌入式软件开发
点赞 评论 收藏
分享
评论
23
1
分享

创作者周榜

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