import io.*; public class count { public static void main( String [] args) { double x; x=ConsoleInput.readDouble("Enter x value"); for(int n=0;n<=10;n++) { eToTheX(x,n); } } public static void eToTheX(double x, int n) { double e=0, nFactorial = 1; for(int i=2; i <=n; i++) { nFactorial *= (double)i; } e+=Math.pow(x,(double)n)/nFactorial; System.out.println("real ex " + Math.exp(x) + " calculated ex " + e); } }
ok so my e+= isnt exactly working... it's just not adding e onto itself each time it displays 11 outputs like i want it to but they dont stack so for e.g. its just x^5/5! when i need x^0/0!+..+..x^5/5! so i need it to output 0,(0..+.. 1),(0+1+2),(0+1+2) thats first 4 results i need that up until its 8+9+10 etc which would be 11 results
so basically