求e的值,e=1+1/1!+1/2!+1/3!+...
小弟我急需~~谢谢个位高手了
參考答案:public class a {
public int jiecheng(int num){
int j = 1;
for(int i = 1; i <= num; i++) {
j = j * i
}
return j;
}
public static void main(String args[]) {
int imput = 10;//这里是要计算到几的阶乘为止
int e = 0;
for(int i = 0; i <= imput; i++) {
e += 1 / jiecheng(i);
}
System.out.println("The answer is : "+e);
}
}