Sorry if this is a simple question, I am not so good in mathematics and trying to start understanding it better. So thanks in advance.
I have this sequence - $0,1,5,6,10,11,15,16,20,21$.... Which is $n$ numbers and then a gap of $n+1$. What I need is a way to get a random number and check if it is part of the sequence.
I see that I can check the last number and see if it is $(0,1,5,6)$ but this will be true only for this sequence. So I need more generic way.
Thanks Shani
edit The sequence starts from $0$ $n = 2$ Then we start with $n$ numbers $(0,1)$ skip $n+1$ numbers $(2,3,4)$ then include $n$ numbers $(5,6)$ , skip $n+1$ $(7,8,9)...$
Okay generally speaking you need to have a formula for the terms of the sequence. In your case the formula seems to be $$a_{2n} = 5n\; , \; a_{2n+1} = 5n+1$$ However it might as well be a completely different formula, this is completely possible!
The basic notion is to try and find the relations between the terms and express them properly.