CS 630 - Computing Fundamentals I - Fall 2005
Homework 4


Loyola College > Department of Computer Science > CS 630 > Homework > Homework 4

Due

Monday, October 10th at the beginning of class

Problems

Exercise (pp. 152-153)
3.2
3.3
3.7

(4) Using Math.Random write a statement that will produce a number between the following endpoints:
(a) 0 to 10
(b) 1 to 10
(c) -10 to 15

Programming Project
3.3 (pg. 153)

Factorial Approximation (myCodeMate DL0099)

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

This is the square root of 2 pi.

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

Assignment

Create a program called FactorialApprox that prompts the user to enter an integer n, calculates the lower and upper bounds for n! using Stirling's Approximation, and then outputs those bounds. 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