Enumerate the primes using only unary arithmetic Write a program which prints the sequence of prime numbers. The shortest solution wins!

All numbers must have a unary representation (not just in the output, but throughout the entire program). This could be a string of 1s, a list of 1s, Peano-style objects, etc.

No particular output format is required, as long as numbers are recognizable. 111, [1, 1, 1], and S(S(S(0))) are all acceptable representations of 3, for example.

Examples of permissible operations:


Appending or prepending a constant value to a string/list
Deleting a constant number of elements from a string/list
Comparing something with a constant, such as "11"
Calling is_empty on a string/list


Examples of what's not allowed:


Any operations on non-unary integers or floats, such as +, %, == or &lt;
Built-in functions which operate on multiple strings/lists, like + or ==
Importing or downloading a library which does unary arithmetic ;-)


Sample programs


Java, with Peano numbers
Python, with strings of 1s
Haskell, 212 135 130 111 104 characters

x⊡[1]=print x&gt;&gt;p x
x⊡s@(_:r)=s∇x where[]∇[]=p x;_∇[]=x⊡r;[]∇y=s∇y;(_:t)∇(_:y)=t∇y
p x=(1:x)⊡x
main=p[1]


The sieve was fun to implement, but simple exhaustive remainder checking is smaller. Strictly adheres to the terms. Unary numbers are represented as lists of 1.

First ten primes:

&amp; runhaskell 13159-UnaryPrimes.hs | head
[1,1]
[1,1,1]
[1,1,1,1,1]
[1,1,1,1,1,1,1]
[1,1,1,1,1,1,1,1,1,1,1]
[1,1,1,1,1,1,1,1,1,1,1,1,1]
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]


No library functions are used at all in the computation. In fact, the only library function used is print, which you can't get away from since you need some library function to output.