0

mr7b ..

To calculate the value of e^x ,, I do this code but I THINK I have mistake . . !

Can any one tell me if it's true or not > ?

```
package calculate;
import java.util.Scanner;
public class Main {
public static void main(String args[]){
double x, n, sum=1 ;
int i;
Scanner read = new Scanner(System.in);
System.out.println("Enter the value of x: ");
x = read.nextDouble();
System.out.println("Enter the value of n: ");
n = read.nextDouble();
for(i = 1; i <= n; i++)
sum = math(x, i);
System.out.println("e^x = "+sum);
}
public static double math(double x, int i){
if (i == 1)
return x;
else
return x /(i-1);
}
}
```

code tags .. I can not use it ,, I don't know why >~

*Edited 6 Years Ago by Nick Evan*: Added code-tags