Pascal's Triangle

A common ``programming project'' for new students, Pascal's Triangle is pretty useful in number theory, probability, and having fun (among others). This particular version came into being after seeing someone in the process of constructing one by hand. I thought that it was really kind of silly to do that when we have computers, which can save you a lot of time and pain (especially if you add something incorrectly). Then I thought for a second and remembered that the only triangle programs I'd ever seen were those silly beginner's course programs, which invariably looked crappy. So I wrote mine. The numbers, as they get longer in length, scale down to a maximum width so that the output looks neat (ie, the bigger the numbers get, the smaller they get..). I also ran into and over another issue: PostScript doesn't have bignums, and it doesn't take long to run into nasties. So, I wrote a one-function cripple bignum library (consisting of one macro, sadd (string add, which, by the way, produces the perfect output to place on a page)). It's a fairly silly algorithm (the bignum addition, that is), but this is PostScript, and doing bignums in PostScript is a fairly idiotic thing to do in the first place.

The program can produce triangles up until your printer's memory limit gives you the finger. You set the number of rows and the starting position, and the program does the rest. The bigger numbers look better at big dpi on small-page printers, and probably just plain better on big-page printers (I don't have one; I produced a bigger triangle by printing out two halves on regular paper and whipping out the glue). You can adjust the line spacing, the max font size, the maximum number width, and the space between numbers. The default comes close to an equilateral triangle.