Golomb sequence

The Golomb sequence is a non-decreasing integer sequence where a(n) is the number of times that n occurs in the sequence, with a(1) = 1.

Since a(1)=1, it means that 1 occurs only once in the sequence, so a(2) must be different. Since the sequence is non-decreasing, a(2) must be greater than 1. Since a(2)>1, the digit 2 must appear more than one time in the sequence. So a(2)=2.

Since a(2)=2, there is two 2 in the sequence, so we know the value of a(3). And so on for the other values of the sequence.

Write a function that computes the Nth element of the sequence.