Code/Magic Sequences

< Return to code directory

This is a toy I made for visualizing the "magic sequences" used for generating expansions of fractions. The magic sequence is defined as:

mag0 = s magi+1 = b ยท magi mod n

Where b is the base, n is the denominator of the fraction, and s is the starting offset. The number of times the value "rolls over" in the modulus determines the digit at that place. The line colors are a color scale from red to blue based on the number of rollovers.