Define a function I(p) from the prime numbers to the integers so that p is the I(p)-th prime. Thus I(2)=1, I(3)=2, and I(7)=4. Define the drawing of any (positive) natural number n recursively as follows:
A simple C++ program can generate such drawings. The output for 163 and 989 appears at the top of this page. Here are some more examples:
Call any set S of nonintersecting, possibly scored, horizontal bars in the plane a configuration if
Then the drawing of any natural number is a configuration, and also any configuration is the drawing of a unique number n.
Let L(n) denote the number of bar segments in the drawing of n. Then L(1)=0, L(2)=1, L(3)=2, and so on. Let P(n) denote the number of positive integers k for which L(k)=n. Then P(0)=1, P(1)=1, and so on. Note that L(65536)=4 even though P(4) is only 55. To calculate P(n) for n > 1, imagine using n segments to construct a configuration. How many ways can we combine the segments? Take any three configurations A, B, and C where L(A) + L(B) + L(C) = n-1. Draw a single segment in the plane. Place A and B in the compartments above and below this segment, respectively. Attach C to the right end of this segment so that C's longest bar meets it. The result is a configuration with n segments. Clearly any nonempty configuration can be constructed in this way, and so P(n) satisfies this recurrence relation:
P(n) = sigma ( P(a) * P(b) * P(c) )
where "sigma" stands for a summation taken over all nonnegative integers a, b, and c for which a+b+c = n-1. And thus, as Simon Plouffe pointed out to me,
P(n) = binomial(3n,n)/(2n+1)
where "binomial" stands for the binomial coefficient.
Let S(n) denote the smallest k such that L(k)=n. Then S(0)=1, S(1)=2, and so on. I don't know a simple formula for S(n).