A127366 Let m = floor(sqrt(n)); if n and m have the same parity, a(n) = n + m, otherwise a(n) = n - m.
0, 2, 1, 4, 6, 3, 8, 5, 10, 12, 7, 14, 9, 16, 11, 18, 20, 13, 22, 15, 24, 17, 26, 19, 28, 30, 21, 32, 23, 34, 25, 36, 27, 38, 29, 40, 42, 31, 44, 33, 46, 35, 48, 37, 50, 39, 52, 41, 54, 56, 43, 58, 45, 60, 47, 62, 49, 64, 51, 66, 53, 68, 55, 70, 72, 57, 74, 59, 76, 61, 78, 63, 80
Offset: 0
Links
Programs
-
Haskell
a127366 n | even n' = n' | otherwise = 2*n - n' where n' = n + a000196 n -- Reinhard Zumkeller, Oct 12 2011
-
Mathematica
a[n_] := If[m = Floor[Sqrt[n]]; OddQ[n] && OddQ[m] || EvenQ[n] && EvenQ[m], n+m, n-m]; Table[ a[n], {n, 0, 72}](* Jean-François Alcover, Nov 30 2011 *)
Comments