I am doing a factorial question with java loop, it asks 1+1/2!+1/3!+...+1/n!, n is positive, I am using "while" to make it, but the code is run with nothing :
public static void main(String[] args) {
double sum=0,a=1;
int n=Integer.parseInt(args[0]);
while(n>0){
a=a*n;
sum=sum+1.0/a;
}
System.out.print(sum);
}
please help:)
nwill not decreased in the while loop.