Terrapin Resources

Factorials

Did you ever wonder how many ways to arrange n distinct objects? The answer is the factorial or the product of all positive integers less than or equal to n. For example, if there are three objects, a, b and c they can be arranged in 3 x 2 x 1 = 6 ways. abc, bca, cab, cba, acb, and bac.

These arrangements are called the permutations of the set of objects. Try a permutation of four objects. (You should have 4 x 3 x 2 x1 = 24 arrangements.) Here are variants of a Logo procedure that will tell you the permutations of any number of objects up to about 150. For those of you into graphics, you should be able experimentally check the theory of the math by arranging the permutations of a more modest number of objects from the toolbox.

FACTORIAL.lgo


Procedure FACTORING, FACTORIAL.FOR, FACTORIAL.WHILE, FACTORIAL.GO, FACTORIAL.RECUR
Description Various ways to calculate the factorial of a number
Level Beginner
Tags Math, Factorial