I have a Nested List that returns a list of numbers which sometimes (but not always) begin to repeat. Here is an example of an instance where the numbers begin repeating :
In[3]:= NestList [ love[#, 37, 42] &, 1, 42 ]
Out[3]= {1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16, 18, 10, 1, 37, 16}
Here, the numbers 1, 37, 16, 18, 10 begin to repeat. I need to run the NestList a full 42 times, because sometimes it returns all unique numbers. But in the cases where numbers repeat, I want to take only the unrepeated numbers and the first repeated number, then stop. For instance, in the example above, I want {1, 37, 16, 18, 10, 1} as my output.
My Question: Is there a simple test I can run or some other means to achieve this?
Also relevant: i do not know how long the repeated sequence will be until execute the input.
Thank you! Please forgive me if it is a very simple fix.