IT5 Lab Exercise 3
It will be checked on December 7, 2010
The factorial method is used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Even for relatively small values of n, the factorial method yields extremely large numbers. For instance, when n is 13, n! is 6227020800—a number too large to be represented with data type Integer (a 32-bit integer value). To calculate the factorials of large values of n, data type Long (a 64-bit integer value) must be used. Write a program that evaluates the factorials of the integers from 1 to 20 using data type Long. Display the results in a two column output table. [Hint: create a Windows application, use Labels as the columns and the vbCrLf constant to line up the rows.] The first column should display the n values (1–20). The second column should display n!.
0 comments:
Post a Comment