1^1+2^2+3^3+4^4+5^5+6^6+7^7+8^8+9^9+10^10 用Java应该怎么写?

如题所述

第1个回答  2019-09-30
虽然很久了,但还是要发一下
搜索的用string那个是错的,string根本不适合
System.out.println(1 + 2 * 2 + 3 * 3 * 3 + 4 * 4 * 4 * 4 + 5 * 5 * 5 * 5 * 5 + 6 * 6 * 6 * 6 * 6 * 6);
是50069
自己可以验证一下
已发博文博文:
第2个回答  2018-10-16
public class Demo {
    public static void main(String[] args) {
        double result = 0;
        for (int i = 1; i <= 10; i++) {
            result += Math.pow(i, i);
        }
        System.out.println(result);
    }
}

相似回答