The factorial of a nonnegative integer n is written as n! (pronounced n factorial) and is defined

Question:

The factorial of a nonnegative integer n is written as n! (pronounced “n factorial”) and is defined for values of n greater than or equal to 1 as:

n! = n · (n – 1) · (n – 2) · … · 1 and for the n value 0 as:

n! = 1 For example, 5! = 5 · 4 · 3 · 2 · 1, which is 120.

a) Write an application that reads a nonnegative integer and computes and prints its factorial.

b) Write an application that estimates the value of the mathematical constant e by using the following formula. Allow the user to enter the number of terms to calculate.

e = 1 + 1 1 + 1!2! + 1 3!

c) Write an application that computes the value of ex by using the following formula. Allow the user to enter the number of terms to calculate.

e* = 1 + ++ 2 +   3! +.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Java How To Program Late Objects Version

ISBN: 9780136123712

8th Edition

Authors: Paul Deitel, Deitel & Associates

Question Posted: