JAVA program help : 1+1!+1/2!+1/3!+ .... 1/N!?

Im using Blue J for Java. Please help me on how to write the program for 1+1!+1/2!+1/3!+ .... 1/N! in Java.

Thank you.

I would also appreciate if you could help me for:

2) x- x^2/2! + x^4/4! - X^6/6! - x^8/8!

3) x/10! + X^2/9! + x^3/8! + x^4/7! + x^5/6!

Please help me. Its 2 AM here in india, and my class is at 6:30 AM.

Re: JAVA program help : 1+1!+1/2!+1/3!+ .... 1/N!?

Quote:

Please help me. Its 2 AM here in india, and my class is at 6:30 AM.

Sure, here you go:

http://www.amazon.co.uk/s/ref=nb_sb_...o+view&x=0&y=0

and also:

Go to sleep. Even if someone haz teh codez, no tutor will believe it is your work if you are unable to talk through exhaustion tomorrow. Maybe showing your tutor my comment will help defuse some of the tension?

Re: JAVA program help : 1+1!+1/2!+1/3!+ .... 1/N!?

Ok, nevermind.

For example, if I declare an int n, is it possible to :

Math.pow (5,n+2) ;

Just this one doubt please!

Re: JAVA program help : 1+1!+1/2!+1/3!+ .... 1/N!?

Specific examples we can help with!

You can of course do what you just posted, but it won't help you (I think) compute (1-to-N)! What you really need to do is to write a method with a signature like 'public static int factorial(int theNumber)' which will multiply theNumber by all numbers smaller than itself and greater than 1. Then you'd write a loop that did the sum of all the reciprocals of factorials from 1 to N.

Re: JAVA program help : 1+1!+1/2!+1/3!+ .... 1/N!?

Quote:

Originally Posted by

**Sean4u**
Specific examples we can help with!

You can of course do what you just posted, but it won't help you (I think) compute (1-to-N)! What you really need to do is to write a method with a signature like 'public static int factorial(int theNumber)' which will multiply theNumber by all numbers smaller than itself and greater than 1. Then you'd write a loop that did the sum of all the reciprocals of factorials from 1 to N.

That was just an example. No way related to the program above.

Im just happy that it will work, thanks alot!

Re: JAVA program help : 1+1!+1/2!+1/3!+ .... 1/N!?

It'll work because Math.pow is pow(double a, double b):

Math (Java Platform SE 6)

'n + 2' is an expression whose value is int if n is an int and double if n is a double (the '2' is an int and would be 'promoted' to double if n is double so that double+double=double can be computed). 5 is an int, so the Java compiler will perform a 'widening primitive conversion' on 5 (and on the result of n + 2, if needed) so that the method invocation matches the Math.pow method signature:

Conversions and Promotions