I have to calculate the value of e which is equal to
e = 1 + 1/1! + 1/2! + 1/3! ...
i know that the factorial for a value is calculated by:
for( int i = 1; i <=n; i++)
fact = fact * i;
JOptionPane.showMessageDialog(null, "fact = " + fact);
so how do i modify this to calculate the value of e?
i tried the following, but my logic is wrong.
for( int i = 1; i <=n; i++)
fact = fact * i;
e = e + 1/fact ;
JOptionPane.showMessageDialog(null, "e = " + e);
As you can see, I am new to Java. Any help would be appreciated!
-Julia
e = 1 + 1/1! + 1/2! + 1/3! ...
i know that the factorial for a value is calculated by:
for( int i = 1; i <=n; i++)
fact = fact * i;
JOptionPane.showMessageDialog(null, "fact = " + fact);
so how do i modify this to calculate the value of e?
i tried the following, but my logic is wrong.
for( int i = 1; i <=n; i++)
fact = fact * i;
e = e + 1/fact ;
JOptionPane.showMessageDialog(null, "e = " + e);
As you can see, I am new to Java. Any help would be appreciated!
-Julia