login
If n is divisible by 4 then 4, if n is divisible by 2 then 2, otherwise n.
1

%I #17 Dec 03 2017 11:49:03

%S 1,2,3,4,5,2,7,4,9,2,11,4,13,2,15,4,17,2,19,4,21,2,23,4,25,2,27,4,29,

%T 2,31,4,33,2,35,4,37,2,39,4,41,2,43,4,45,2,47,4,49,2,51,4,53,2,55,4,

%U 57,2,59,4,61,2,63,4,65,2,67,4,69,2,71,4,73,2,75,4,77,2,79,4,81,2,83,4,85,2,87,4,89,2

%N If n is divisible by 4 then 4, if n is divisible by 2 then 2, otherwise n.

%C Suggested by a puzzle in Mitteilungen der DMV, although I do not know if this solution is what they had in mind.

%C a(A008586(n)) = 4; a(A005408(n)) = A005408(n). - _Reinhard Zumkeller_, Oct 09 2013

%D Frank Lutz and Brigitte Lutz-Westphal, Eigenwillige Zahlen, Mitteilungen der DMV, 2013, Band 21, Heft 1 (p. 32).

%H <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0,1,0,1,0,-1).

%F Conjecture: a(n) = (3+3*(-1)^n+(-i)^n+i^n+n-(-1)^n*n)/2 where i=sqrt(-1). G.f.: -x*(4*x^5-x^4-2*x^3-2*x^2-2*x-1) / ((x-1)^2*(x+1)^2*(x^2+1)). - _Colin Barker_, Oct 09 2013

%p f:=proc(n) if (n mod 4) = 0 then 4 elif (n mod 4) = 2 then 2; else n; fi; end;

%t Table[Which[Divisible[n,4],4,Divisible[n,2],2,True,n],{n,100}] (* or *) LinearRecurrence[{0,1,0,1,0,-1},{1,2,3,4,5,2},100] (* _Harvey P. Dale_, Dec 03 2017 *)

%o (Haskell)

%o a230089 n = if odd n then n else if mod n 4 == 0 then 4 else 2

%o -- _Reinhard Zumkeller_, Oct 09 2013

%Y Cf. A005843.

%K nonn,easy

%O 1,2

%A _N. J. A. Sloane_, Oct 08 2013