求阶乘的.Public class Test{ public static long jiecheng(long number){ long temp=1; for(int i=1;i<=number;){ temp*=i; } return temp; } public static void main(String ...args){ System.out.println(jiecheng(3)+jiecheng(5)+jiecheng(7)+jiecheng(9)); } }
9楼的哥们 有点意思 我也想明白了些 public static void method2(){ int count=0; for(int i=1;i<=5;i++){ int ji=1; //求i的阶乘 for(int j=1;j<=i;j++){ ji*=j; // } count+=ji; } System.out.println(count); }
public class factorial {
public static void main(String...args) { //3!+5!+7!+9!=???? System.out.println(sum(5)); } private static long sum(int n) { int long_sum = 0; for(int i = 2; i<=n; i++) { int temp = 1; for(int j = 1; j<=2*i-1; j++) { temp = temp*j; } long_sum += temp; } return long_sum; } }供参考
public static long jiecheng(long number){
long temp=1;
for(int i=1;i<=number;){
temp*=i;
}
return temp;
}
public static void main(String ...args){
System.out.println(jiecheng(3)+jiecheng(5)+jiecheng(7)+jiecheng(9));
}
}
public static void method2(){
int count=0;
for(int i=1;i<=5;i++){
int ji=1; //求i的阶乘
for(int j=1;j<=i;j++){
ji*=j; //
}
count+=ji;
}
System.out.println(count);
}
public static void main(String...args) {
//3!+5!+7!+9!=????
System.out.println(sum(5));
}
private static long sum(int n) {
int long_sum = 0;
for(int i = 2; i<=n; i++) {
int temp = 1;
for(int j = 1; j<=2*i-1; j++) {
temp = temp*j;
}
long_sum += temp;
}
return long_sum;
}
}供参考
for(int i=1;i<=number;){
temp*=i;
}
return temp;
.................6v信息平台http://www.6vie.com
外包服务http://www.datacomasia.com/