cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A114112 a(1)=1, a(2)=2; thereafter a(n) = n+1 if n odd, n-1 if n even.

This page as a plain text file.
%I A114112 #85 Jun 29 2025 02:14:29
%S A114112 1,2,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19,22,21,24,23,26,25,
%T A114112 28,27,30,29,32,31,34,33,36,35,38,37,40,39,42,41,44,43,46,45,48,47,50,
%U A114112 49,52,51,54,53,56,55,58,57,60,59,62,61,64,63,66,65,68,67,70,69,72,71
%N A114112 a(1)=1, a(2)=2; thereafter a(n) = n+1 if n odd, n-1 if n even.
%C A114112 a(1)=1; for n>1, a(n) is the smallest positive integer not occurring earlier in the sequence such that a(n) does not divide Sum_{k=1..n-1} a(k). - _Leroy Quet_, Nov 13 2005 (This was the original definition. A simple induction argument shows that this is the same as the present definition. - _N. J. A. Sloane_, Mar 12 2018)
%C A114112 Define b(1)=2; for n>1, b(n) is the smallest number not yet in the sequence which shares a prime factor with the sum of all preceding terms. Then a simple induction argument shows that the b(n) sequence is the same as the present sequence with the first term omitted. - _David James Sycamore_, Feb 26 2018
%C A114112 Here are the details of the two induction arguments (Start)
%C A114112 For a(n), let A(n) = a(1)+...+a(n). The claim is that for n>2 a(n)=n+1 if n odd, n-1 if n even.
%C A114112 The induction hypotheses are: for i<n, a(2i)=2i+1, a(2i)=2i-1, A(2i)=i(2i+1), A(2i) = 2i^2+3i+2. This implies that when looking for a(2i), we have seen all the numbers 1 through 2i except 2i-1, so the two smallest candidates for a(2i) are 2i-1 and 2i+1. Since 2i-1 does not divide 2i^2-i-1, a(n)=2i-1. When looking for a(2i+1), we have seen all the numbers 1 through 2i already, so the two smallest candidates for a(2i+1) are 2i+1 and 2i+2. But 2i+1 does divide A(2i) and 2i+2 does not, so a(2i+1)=2i+2. QED
%C A114112 For b(n), the argument is very similar, except that the missing numbers when looking for b(n) are slightly different, and  (setting B(n) = b(1)+...b(n)), we have B(2i)=(i+1)(2i+1), B(2i+1)=(i+2)(2i+1). - _N. J. A. Sloane_, Mar 14 2018
%C A114112 When sequence a(n) is increasing, then the Cesàro means sequence c(n) = (a(1)+...+a(n))/n is also increasing, but the converse is false. This sequence is a such an example where c(n) is increasing, while a(n) is not increasing (Arnaudiès et al.). See proof in A354008. - _Bernard Schott_, May 11 2022
%D A114112 J. M. Arnaudiès, P. Delezoide et H. Fraysse, Exercices résolus d'Analyse du cours de mathématiques - 2, Dunod, Exercice 10, pp. 14-16.
%H A114112 Vincenzo Librandi, <a href="/A114112/b114112.txt">Table of n, a(n) for n = 1..2000</a>.
%H A114112 ProofWiki, <a href="https://proofwiki.org/wiki/Cesàro_Mean">Cesàro mean</a>.
%H A114112 Wikipedia, <a href="https://en.wikipedia.org/wiki/Ernesto_Cesàro">Ernesto Cesàro</a>.
%H A114112 Wikipédia, <a href="https://fr.wikipedia.org/wiki/Lemme_de_Cesàro">Lemme de Cesàro</a> (in French).
%H A114112 <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,1,-1).
%F A114112 G.f.: x*(x^4-2*x^3+x^2+x+1)/((1-x)*(1-x^2)). - _N. J. A. Sloane_, Mar 12 2018
%F A114112 The g.f. for the b(n) sequence is x*(x^3-3*x^2+2*x+2)/((1-x)*(1-x^2)). - Conjectured (correctly) by _Colin Barker_, Mar 04 2018
%F A114112 E.g.f.: 1 - x + x^2/2 + (x - 1)*cosh(x) + (x + 1)*sinh(x). - _Stefano Spezia_, Sep 02 2022
%F A114112 Sum_{n>=1} (-1)^(n+1)/a(n) = 1 - log(2) (A244009). - _Amiram Eldar_, Jun 29 2025
%t A114112 a[1] = 1; a[n_] := a[n] = Block[{k = 1, s, t = Table[ a[i], {i, n - 1}]}, s = Plus @@ t; While[ Position[t, k] != {} || Mod[s, k] == 0, k++ ]; k]; Array[a, 72] (* _Robert G. Wilson v_, Nov 18 2005 *)
%o A114112 (PARI) a(n) = if (n<=2, n, if (n%2, n+1, n-1)); \\ _Michel Marcus_, May 16 2022
%o A114112 (Python)
%o A114112 def A114112(n): return n + (0 if n <= 2 else -1+2*(n%2)) # _Chai Wah Wu_, May 24 2022
%Y A114112 All of A014681, A103889, A113981, A114112, A114285 are essentially the same sequence. - _N. J. A. Sloane_, Mar 12 2018
%Y A114112 Cf. A114113 (partial sums).
%Y A114112 See A084265 for the partial sums of the b(n) sequence.
%Y A114112 About Cesàro mean theorem: A033999, A141310, A237420, A354008.
%Y A114112 Cf. A244009.
%K A114112 easy,nonn
%O A114112 1,2
%A A114112 _Leroy Quet_, Nov 13 2005
%E A114112 More terms from _Robert G. Wilson v_, Nov 18 2005
%E A114112 Entry edited (with simpler definition) by _N. J. A. Sloane_, Mar 12 2018