Fractal Curves Generated by the Sum-of-Digits Function

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Fractal-like curves are generated by the sum-of-digit function for a given base with two additional parameters and . In some special cases, these curves reduce to known fractals; for example, when and , the curve is a scaled version of  the famous Koch curve. For general parameters and , the curves can take on a remarkable and largely unpredictable variety of shapes, from distinctive geometric shapes to fractal-like patterns to random clouds exhibiting no apparent pattern.

Contributed by: Adithya Swaminathan, Dimitrios Tambakos and A. J. Hildebrand (June 2021)
(Based on an undergraduate research project at the Illinois Geometry Lab in Spring 2021)
Open content licensed under CC BY-NC-SA



Let be the base- representation of . The the sum-of-digits function of in base is defined to be .

The curves shown in this Demonstration are constructed as follows. Fix an integer and two parameters and , and let 


Let be the polygonal curve that starts at the origin and whose steps are unit vectors in the direction of the angles , . Thus, is the infinite curve obtained by connecting the partial sums

, ,

interpreted as points in the complex plane (with the empty sum interpreted as ).

There are several special cases that are of particular interest:

• When and , the curve  is a scaled version of the Koch curve [1]. The point at step is ,  where is the Thue–Morse sequence, defined by if the sum of binary digits of  is even, and otherwise.  

• When , is an integer and is congruent to or modulo , the curve is periodic and represents a finite polygonal curve that can be explicitly described [2]. 

• When , the angles reduce to and so do not depend on the sum-of-digit function. The resulting curves are known as curlicue fractals [3]. 

• When and are integers, the curve encodes the behavior of the sum-of-digit function , with restricted to an arithmetic progression modulo , in residue classes modulo [1, 4].  

• For general parameters and , the behavior of is more mysterious, and very little is known of such cases.


[1] J.-P. Allouche and G. Skordev, "Von Koch and Thue–Morse Revisited," Fractals, 15(4), 2007 pp. 405–409. doi:10.1142/S0218348X07003630.

[2] D. H. Lehmer and E. Lehmer, "Picturesque Exponential Sums, I," The American Mathematical Monthly, 86(9), 1979 pp. 725–733. doi:10.1080/00029890.1979.11994899.

[3] F. M. Dekking and M. Mendès France, "Uniform Distribution Modulo One: A Geometrical Viewpoint," Journal für die reine und angewandte Mathematik, 1981(329), 1981 pp. 143–153. doi:10.1515/crll.1981.329.143.

[4] F. M. Dekking, "On the Distribution of Digits in Arithmetic Sequences," Séminaire de théorie des nombres de Bordeaux (1982–1983), Bordeaux: Société Arithmétique de Bordeaux, 1982 pp. 1–12.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.