CS 630 - Computing Fundementals I - Spring 2004
Problem 1 - Math Functions


Loyola College > Department of Computer Science > CS 630 > Homework > Problem 1

Objectives

Introduction

For any integer n > 0, n! is defined as the product 1 * 2 * ... * n. It is sometimes useful to have a closed-form instead; for this purpose an approximation can be used. In 1730 J. Stirling came up with such an approximation, which can be expressed as

Eric Weisstein's World of Mathematics has a page on Stirling's Approximation.

Assignment

Create a program called FactorialApproximator that prompts the user to enter an integer n, calls functions which calculate the lower and upper bounds for n! using Stirling's Approximation, and then displays those bounds in the terminal. The message should look something like this (of course, the actual numbers will depend on the user's input):
1.551104102634359E25 <= 25! <= 1.5511212799620605E25

Hints