The sequence starts with a number of your choosing. To find the next number in the sequence, count the number of times the current number has appeared previously in the sequence. for example, if the sequence started with 2, then the next number would be 0, because the number 2 has not appeared anywhere in the sequence (which is currently only 2 numbers) the number after 0 would be 0, because the number 0 hasn't appeared in the sequence previously. However, the next number would be 1, because in the sequence 2-0-0, zero has appeared once before the current number. The next number would be 0, then 2, etc. The code itself actually does not have to recheck the whole sequence when finding the repeats, because all you have to do is figure out the current number of times the number has been repeated, then add 1 to that the next time it appears, then add 1 to that the next time it appears, and so on.
its called the plagiarist sequence because im pretty sure it already exists