Finding the $n$th term of some sequences given by its few first terms Does anyone know how to find the $n$th term of the following sequences:
$(1)\ $ $1,0,0,0,1,0,0,0,1,0,0,0,1,....\\$
$(2)\ $1,0,0,0,-1,0,0,0,1,0,0,0,-1,....\ $
$(3)\ $ $1,0,-1/2,0,1/3,0,-1,4,0,...\\$
$(4)\ $ $1,0,3/2,0,2/3,0,5/4,0,4/5,0,7/6,...$
I managed to get the first one which is $z_n=\frac{1}{2}(a_n+b_n)$ where $a_n=\frac{1}{2}(1^n+(-1)^n)$ and $b_n=\frac{1}{2}(i^n+(-i)^n)$. anyone has an idea how to get the other sequences?
 A: 671958
1
If $n\equiv{0}\mod{4}$, then
....member = 1
else
....member = 0
endif
2
If $n\equiv{0}\mod{8}$, then
....member = 1
elseif $n\equiv{4}\mod{8}$ then
....member = -1
else
....member = 0
endif
3
NOTA BENE: I assume this one had a typo.
if $n\equiv{1}\mod{2}$ then
....member = 0
else
....if $n\equiv{0}\mod{4}$ then
........member = $\frac2{n+2}$
....else
........member = $-\frac2{n+2}$ (NOT an error!)
....endif
endif
4
if n = 0 then 
....member = 1 
else 
....if $n\equiv{1}\mod{2}$ then 
........member = 0 
....else 
........if $n\equiv{2}\mod{4}$ then
............member = ${{n+4}\over{n+2}}$ 
........else 
............member = $n\over{n+2}$ (NOT an error!) 
........endif 
....endif 
endif
A: Here's a way to look at the 3rd one. 
$1,1/2,1/3,1/4,\dots$ would be $1/n$. 
$1,-1/2,1/3,-1/4,\dots$ would be $(-1)^{n-1}(1/n)$. 
$1,0,-1/2,0,1/3,0,-1/4,\dots$, well, the nonzero terms are $(-1)^{(n-1)/2}{2\over n+1}$ so we can go with $$(-1)^{(n-1)/2}{1-(-1)^n\over n+1}$$ This can probably be simplified. But the main idea is to take it a piece at a time, building up to the sequence you want by way of simpler ones. Can you use these same ideas to do the 4th question?
