Digit Occurrence Graphing
Overview
A cool little C program to count the occerances of every digit from zero to your chosen number. This program is optimized for speed and can quickly process large numbers, even into the millions.
While walking through the engineering building one day, I stumbled upon some friends working on a combinatorics problem. Their goal was to determine how many times each digit appears while counting to one million. Being the helpful fellow I am, I pulled out my laptop and started brute-forcing the problem with a C program. While the resulting program was, unfortunately, not an acceptable solution, it did produce the correct count—along with a cool fractal.

Play with it!
First, obtain the files. They are found on my Github and here as a zip. To compile and run the program on Linux, follow these steps:
- Navigate to the project directory in your terminal.
- Compile the C source code using GCC:
gcc -o digits digits.c
- Run the program:
./digits <end-number>
Output is saved in a file, and is of the form:
<current number> <zeros in current> <zeros running total> <ones in current> <ones running total> ... <nines in current> <nines running total>
Plotting the count of each digit as the number gets larger produces the plot seen above. As the number continues to grow the pattern repeats (for each 10x).
Cool video
A video of the results in an animated GNUPlot: YouTube