Write a program to prompt the user to key in x and n value to calculate the result for the following formula:
Result = 1 + 2!/(x-2) - 3!/(x-3)+ 4!/(x-4)-.....n!/(x-n)
Note: x value must be greater than n value.
Sample Run 1
Please key in x value : 8
Please key in n value : 5
Result: 1 + 2!/6 + 3!/5 + 4!/4 + 5!/3 =-33.8667
it appears he just trying to calculate a taylor polynomial. I would suggest start by breaking the requirements down into manageable pieces.
1) Write a function called factorial that will calculate the factorial of a number. You need to be strict on the requirements because this can quickly overflow for large values of N if you are using primitive types. For large values of N, you will need to write you own data-structure to hold large numbers. If you want to make the function efficient, look into a technique called memoization.
Once you have that taken care of, the rest should be fairly easy. Once you have some code post back here, and I will help the best I can. I don't want to give to much away if this is homework though.