G
[G.P]Georgy™
Hey guys !
I have to solve this following question:
Determine the value of e(x), where:
e(x) = 1 + x/1! + x²/2! + x³/3! + …
Consider the terms of the sum until the difference between the values
obtained
with addiction of two consecutive terms be inferior to 0,0001.
What I succeed was this code:
public class Factorial {
static int fact(int n){
int f = 1, i = 1;
while (i < n){
i = i + 1;
f = f * i;
}
return f;
}
public static void main (String args[]){
float difference = 1;
//this variable will acumulate the sum until (difference <
0.0001).
//starts with 1, the first term of the sum.
float e = 1;
int x = 8;
while(difference < 0.0001){
//(????)
//I don't know how can I calculate this difference; what
terms I use to do this difference?
}
}
}
any idea for me??
thank you !
I have to solve this following question:
Determine the value of e(x), where:
e(x) = 1 + x/1! + x²/2! + x³/3! + …
Consider the terms of the sum until the difference between the values
obtained
with addiction of two consecutive terms be inferior to 0,0001.
What I succeed was this code:
public class Factorial {
static int fact(int n){
int f = 1, i = 1;
while (i < n){
i = i + 1;
f = f * i;
}
return f;
}
public static void main (String args[]){
float difference = 1;
//this variable will acumulate the sum until (difference <
0.0001).
//starts with 1, the first term of the sum.
float e = 1;
int x = 8;
while(difference < 0.0001){
//(????)
//I don't know how can I calculate this difference; what
terms I use to do this difference?
}
}
}
any idea for me??
thank you !