dc, 47 bytes, 0 indexed
?0sb1se[0sble1+se]sf[lb1+dsble=f1-d0!>c]dscxlbp
Try It Online!
Explanation
This explanation assumes that the input is 100.
? # Ask for inout and store it on top of the main stack.
# Main = [100].
0sb1se # Store 0 on top of register "b" and 1 on top of register "e" to be referenced later.
# b = [0], e = [1], Main = [100].
[0sble1+se]sf # Store the macro "0sble1+se" on top of register "f".
# f = [0sble1+se], b = [0], e = [1], Main = [100].
[lb1+dsble=f1-d0!>c]dscx # Store the macro "lb1+dsble=f1-d0!>c" on top of Main stack, duplicate it, and then store one copy on top of register "c" and then immediately executing the other copy as a dc program.
# c = [lb1+dsble=f1-d0!>c], f = [0sble1+se], b = [0], e = [1], Main = [100]
================================================================================================================================================================================================================================================
Upon invocation of the macro `lb1+dsble=f1-d0!>c`:
lb1+dsble # Load (not pop) the value off of the top of register "b" on top of the main stack, add 1 to it, duplicate the sum, and then push one copy to the top of register "b".
# Then, load the value off of the top of "e" onto the main stack.
# b = [0,1], e = [1], Main = [100,1,1].
le=f # Now, pop the top 2 values (1 and 1), compare them, and invoke the macro on top of register "f" if both are equal. In this case, it is invoked, since 1==1.
# b = [0,1], e = [1], Main = [100].
======================================================================================================================================================================================
If the macro on top of "f" (`0sble1+se`) is invoked:
0sble1+se # Push 0 to the top of the Main stack. Then, push it to the top of register "b", resetting the sequence, after which the value on top of "e" is loaded onto the main stack.
# Then, this value is incremented by 1. This new value os finally pushed to the top of register "e".
# b = [0,1,0], e = [1, 2], Main = [100]
======================================================================================================================================================================================
1-d0!>c # Finally, decrement the value on top of the Main stack (the input) by 1, duplicate this, pop and compare this value with 0, and as long as the `input-1`>=0, keep on executing this macro.
# b = [0,1,0], e = [1, 2], Main = [100,99]
================================================================================================================================================================================================================================================
lbp # Finally, once all the iterations of the macros have taken place, load the n'th value of the sequence off of the top of register "b", and then output it.
# At the end, b = [0,1,0,1,2,0,1,2,3,0,1,2,3,4,...] and Main=[100,99,...,0,-1].
59,100, etc) – FlipTack 15 hours ago