1. Member Join Date
Feb 2013
Posts
33
Rep Power
0

## Can someone please help me?

I need help on a part of my code
I'm asked to write an application that computes the value of e^x by using the following formula. Allow the user to enter the number of terms to calculate. (part c)

e^x = 1 + (x/1!) + (x^2/2!) + (x^3/3!) + ...

this is what I have so far:
(need help on part c)

PHP Code:
```public class Factorial {

public static long factorial( int n )
{
if( n <= 1 )
return 1;
else
return n * factorial( n - 1 );
}

public static void main( String [] args ) {
long factorial = 1;
double e = 1.0;
double ex = 10.0;

//// part a ////
for (int i = 1; i <= 20; i++) {
factorial = factorial * 1;
System.out.println( i + "! = " + factorial (i) );
}

//// part b ////
System.out.printf("\n\n e is approximately ", e);
factorial = 1;
for (int i = 1; i <= 20; i++) {
factorial = factorial * i;
e = e + 1.0 / factorial;
}
System.out.printf("%f ", e);

//// part c ////
System.out.printf("\n\n e to the x is approximately : ");
for (int count = 1; count < 5; count++) {
ex = Math.pow(e, count) / factorial;
}
System.out.printf("%f \n\n", ex);

}
}```  Reply With Quote

2. ## Re: Can someone please help me?

1. Please edit your question title so that it's informative. Yours currently states, "Can someone please help me" which tells us nothing that we don't already know -- you wouldn't be posting here if you didn't need help. Instead edit it so that it summarizes your actual problem as this is the best way of attracting experts in your current problem to your question.
2. You state your assigment and your code, but you tell us nothing about the problem you're currently having. What's wrong with your current code? What specific questions do you have? Understand that no one is going to complete your assignment for you, but we'd love to help you, but without a question, most of us really won't know how to help.  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•