%I #35 Oct 18 2019 03:46:47
%S 0,1,1,2,3,5,1,6,2,8,4,12,5,17,10,1,11,4,15,8,23,16,7,23,14,1,15,6,21,
%T 12,33,24,11,35,26,13,39,30,12,42,33,15,48,39,21,2,23,14,37,28,10,38,
%U 29,11,40,31,13,44,35,17,52,43,25,6,31,22,4,26,17,43,34,16,50,41,23,4,27,18,45,36
%N a(0) = 0, a(1) = 1; for n > 1, a(n) = a(n-1) + a(n-2) if a(n-1) > k, where k is each element in the ordered set M of integers not in 0 .. maximum(a(n-1)). Otherwise a(n+i) = a(n+i-1) - k, 0 <= i < #M.
%C The sequence has the same next-term addition rule as the Fibonacci sequence A000045. However any number between 0 and the maximum value of a(0)..a(n) that has not appeared in the sequence is added to an ordered set M of missing numbers. These are subsequently subtracted from a(n-1) to form a(n), a(n+1)..a(n+i) as long as the resulting a(n) >= 0. At any time if a(n) appears in the set of currently missing numbers that number is removed from the set.
%C The sequence has 137 non-repeating values, the largest being 55, and the last element being 49. Beyond this the final 30 values of the sequence 30, 10, 40, 21, 1, 22, 3, 25, 6, 31, 12, 43, 24, 4, 28, 9, 37, 18, 55, 36, 16, 52, 33, 13, 46, 27, 7, 34, 15, 49 repeat forever, with an unchanging set M of missing values {19,20,32,47,51,54}.
%H Scott R. Shannon, <a href="/A328145/b328145.txt">Table of n, a(n) for n = 0..1000</a>
%H Scott R. Shannon, <a href="/A328145/a328145.java.txt">Java code to produce the sequence</a>.
%e a(0..5) = 0,1,1,2,3,5. As 4 was skipped it is added to the set M of missing values, so M = {4}. As a(5) >= 4 the next value is thus a(6) = 5 - 4 = 1. As there are no more missing numbers to process, the addition rule starts again, so a(7) = 5 + 1 = 6.
%e a(9) = 6 + 2 = 8. which skips 7, so M = {4,7}.
%e a(10) = 8 - 4 = 4, which removes 4 from M. As the remaining missing value 7 is greater than 4, the next value is a(11) = 4 + 8 = 12, which adds 9, 10, 11 to M so M = {7,9,10,11}.
%e a(13) = 17 - 7 = 10, removing 10 from M. But 10 is also larger than the next missing value 9, thus a(14) = 10 - 9 = 1. a(15) = 10 + 1 = 11, removing 11 from M.
%e The value 7 is eventually reached at a(22), and 9 at a(92). After 137 values the above given series of 30 values repeats with M = {19,20,32,47,51,54}.
%Y Cf. A000045.
%K nonn
%O 0,4
%A _Scott R. Shannon_, Oct 05 2019