login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A004442 Natural numbers, pairs reversed: a(n) = n + (-1)^n; also Nimsum n + 1. 55

%I #75 Aug 08 2023 04:14:30

%S 1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14,17,16,19,18,21,20,23,22,25,24,

%T 27,26,29,28,31,30,33,32,35,34,37,36,39,38,41,40,43,42,45,44,47,46,49,

%U 48,51,50,53,52,55,54,57,56,59,58,61,60,63,62,65,64,67,66,69

%N Natural numbers, pairs reversed: a(n) = n + (-1)^n; also Nimsum n + 1.

%C A self-inverse permutation of the natural numbers.

%C Nonnegative numbers rearranged with least disturbance to maintain a(n) not equal to n. - _Amarnath Murthy_, Sep 13 2002

%C Essentially lodumo_2 of A059841. - _Philippe Deléham_, Apr 26 2009

%C a(n) = A180176(n) for n >= 20. - _Reinhard Zumkeller_, Aug 15 2010

%D E. R. Berlekamp, J. H. Conway and R. K. Guy, Winning Ways, Academic Press, NY, 2 vols., 1982, see p. 60.

%D J. H. Conway, On Numbers and Games. Academic Press, NY, 1976, pp. 51-53.

%H Michael De Vlieger, <a href="/A004442/b004442.txt">Table of n, a(n) for n = 0..10000</a>

%H Paul Barry, <a href="https://arxiv.org/abs/2004.04577">On a Central Transform of Integer Sequences</a>, arXiv:2004.04577 [math.CO], 2020.

%H <a href="/index/Ni#Nimsums">Index entries for sequences related to Nim-sums</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

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

%F a(n) = n XOR 1. - _Odimar Fabeny_, Sep 05 2004

%F G.f.: (1-x+2x^2)/((1-x)*(1-x^2)). - Mitchell Harris, Jan 10 2005

%F a(n+1) = lod_2(A059841(n)). - _Philippe Deléham_, Apr 26 2009

%F a(n) = 2*n - a(n-1) - 1 with n > 0, a(0)=1. - _Vincenzo Librandi_, Nov 18 2010

%F a(n) = Sum_{k=1..n-1} (-1)^(n-1-k)*C(n+1,k). - _Mircea Merca_, Feb 07 2013

%F For n > 1, a(n)^a(n) == 1 (mod n). - _Thomas Ordowski_, Jan 04 2016

%F Sum_{n>=0,n<>1} (-1)^n/a(n) = log(2) = A002162. - _Peter McNair_, Aug 07 2023

%p a[0]:=1:a[1]:=0:for n from 2 to 70 do a[n]:=a[n-2]+2 od: seq(a[n], n=0..68); # _Zerinvary Lajos_, Feb 19 2008

%t Table[n + (-1)^n, {n, 0, 72}] (* or *)

%t CoefficientList[Series[(1 - x + 2x^2)/((1 - x)(1 - x^2)), {x, 0, 72}], x] (* _Robert G. Wilson v_, Jun 16 2006 *)

%t Flatten[Reverse/@Partition[Range[0,69],2]] (* or *) LinearRecurrence[{1,1,-1},{1,0,3},70] (* _Harvey P. Dale_, Jul 29 2018 *)

%o (Haskell)

%o import Data.List (transpose)

%o import Data.Bits (xor)

%o a004442 = xor 1 :: Integer -> Integer

%o a004442_list = concat $ transpose [a005408_list, a005843_list]

%o -- _Reinhard Zumkeller_, Jun 23 2013, Feb 01 2013, Oct 20 2011

%o (PARI) a(n)=n+(-1)^n \\ _Charles R Greathouse IV_, Nov 20 2012

%o (PARI) Vec((1-x+2*x^2)/((1-x)*(1-x^2)) + O(x^100)) \\ _Altug Alkan_, Feb 04 2016

%o (Python)

%o def a(n): return n^1

%o print([a(n) for n in range(69)]) # _Michael S. Branicky_, Jan 23 2022

%Y Cf. A003987, A004443, A004444. Equals A014681 - 1.

%Y Cf. A005843, A005408, A059841.

%Y Cf. A002162

%K nonn,easy,nice

%O 0,3

%A _N. J. A. Sloane_

%E Offset adjusted by _Reinhard Zumkeller_, Mar 05 2010

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 28 09:58 EDT 2024. Contains 372037 sequences. (Running on oeis4.)