Below is a program in Qbasic that will draw the graphical analysis graph of the fraction n/d in base b. The image will have neither axes nor the line y = x, but only the figure itself on a bed of white space. This program was written for a 386 running MS-DOS, so some adjustments may be necessary for less primitive machines.
I'm curious to
know what people's tastes are in fractions. So if you find some fractions
that you think are particularly beautiful, I'd like to know about them.
Also, if you have any questions or comments, please do not hesitate to
contact me. My email address is
PRINT "Which fraction shall I analyze? Use the form numerator, denominator" INPUT n,d PRINT "In which base?" INPUT b LET rem1 = n FOR i = 1 TO (d - 1) LET rem2 = (((rem1*b)/d) - INT(((rem1*b)/d))) * d REM the previous line multiplies by $b$ and mods by $d$ to find the new remainder. IF (rem2 - FIX(rem2)) >= .5 then LET rem2 = FIX(rem2) + 1 IF (rem2 - FIX(rem2)) < .5 then LET rem2 = FIX(rem2) REM these two lines round the new remainder to the nearest integer to avoid REM the introduction of small errors which, because of the iteration, REM grow rapidly SCREEN 12 LET s = 400 / (d - 1) REM this is a scaling factor, needed because image size depends on REM the size of the denominator. It puts the image in a 400-pixel square. LINE (rem1 * s, 400 - (rem1 * s)) - (rem1 * s, 400 - (rem2 * s)) REM draws vertical line LINE (rem1 * s, 400 - (rem2 * s)) - (rem2 * s, 400 - (rem2 * s)) REM draws horizontal line IF rem2 = n then GOTO 1 LET rem1 = rem2 NEXT i 1 END
MAA Online is edited by Fernando Q. GouvÍa (email@example.com). Last modified: Sat Jun 03 09:49:46 -0500 2000