22智能在线
新记
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);
}
}
相似回答
大家正在搜
相关问题
1^1+2^2+3^3+4^4+5^5+6^6+7^7+8^...
1^1-2^2+3^3-4^4+5^5-6^6+7^7-8^...
1^1+2^2+3^3+4^4+5^5+6^6
1+2^2+3^3+4^4+5^5+6^6+7^7+8^8+...
1*2+2*3+3*4+4*5+5*6+6*7+7*8+8*...
(1的一次方+2的2次方+3的3次方+4的4次方+5的5次方...
求大佬用JAVA编程计算1^1+2^2+3^3+4^4+5^...
1*2+2*3+3*4+4*5+5*6+6*7+7*8+8*...