I am pretty much sure that r=(1-(-1)^n)/2 and R=... that I have given earlier as a reply is exactly what he wanted. And in fact did u (Hurkyl) try the formula of N mod 4? N mod 2 is sure to work. If you are interested then try n mod 3? I mean make a mathematical function which passes a number n...