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.

A332542 a(n) is the smallest k such that n+(n+1)+(n+2)+...+(n+k) is divisible by n+k+1.

This page as a plain text file.
%I A332542 #52 Aug 27 2021 11:19:53
%S A332542 2,7,14,3,6,47,14,4,10,20,25,11,5,31,254,15,18,55,6,10,22,44,14,23,11,
%T A332542 7,86,27,30,959,62,16,34,8,73,35,17,24,163,39,42,127,9,22,46,92,62,19,
%U A332542 23,15,158,51,10,20,75,28,58,116,121,59,29,127,254,11
%N A332542 a(n) is the smallest k such that n+(n+1)+(n+2)+...+(n+k) is divisible by n+k+1.
%C A332542 Note that (n+(n+1)+(n+2)+...+(n+k))/(n+k+1) = A332544(n)/(n+k+1) = A082183(n-1). See the Myers et al. link for proof. - _N. J. A. Sloane_, Apr 30 2020
%C A332542 We can always take k = n^2-2*n-1, for then the sum in the definition becomes (n+1)*n*(n-1)*(n-2)/2, which is an integral multiple of n+k+1 = n*(n-1). So a(n) always exists. - _N. J. A. Sloane_, Feb 20 2020
%H A332542 Seiichi Manyama, <a href="/A332542/b332542.txt">Table of n, a(n) for n = 3..10000</a>
%H A332542 J. S. Myers, R. Schroeppel, S. R. Shannon, N. J. A. Sloane, and P. Zimmermann, <a href="http://arxiv.org/abs/2004.14000">Three Cousins of Recaman's Sequence</a>, arXiv:2004:14000  [math.NT], 2020-2021.
%e A332542 n=4: we get 4 -> 4+5=9 -> 9+6=15 -> 15+7=22 -> 22+8=30 -> 30+9=39 -> 39+10=49 -> 49+11=60, which is divisible by 12, and took k=7 steps, so a(4) = 7. Also A332543(4) = 12, A332544(4) = 60, and A082183(3) = 60/12 = 5.
%p A332542 grow2 := proc(n,M) local p,q,k; # searches out to a limit of M
%p A332542 # returns n, k (A332542(n)), n+k+1 (A332543(n)), p (A332544(n)), and q (which appears to match A082183(n-1))
%p A332542 for k from 1 to M do
%p A332542    if ((k+1)*n + k*(k+1)/2) mod (n+k+1) = 0 then
%p A332542    p := (k+1)*n+k*(k+1)/2;
%p A332542    q := p/(n+k+1); return([n,k,n+k+1,p,q]);
%p A332542    fi;
%p A332542 od:
%p A332542 # if no success, return -1's
%p A332542 [n,-1,-1,-1,-1]; end; # _N. J. A. Sloane_, Feb 18 2020
%t A332542 a[n_] := NestWhile[#1+1&,0,!IntegerQ[Divide[(#+1)*n+#*(#+1)/2,n+#+1]]&]
%t A332542 a/@Range[3,100] (* _Bradley Klee_, Apr 30 2020 *)
%o A332542 (Ruby)
%o A332542 def A(n)
%o A332542   s = n
%o A332542   t = n + 1
%o A332542   while s % t > 0
%o A332542     s += t
%o A332542     t += 1
%o A332542   end
%o A332542   t - n - 1
%o A332542 end
%o A332542 def A332542(n)
%o A332542   (3..n).map{|i| A(i)}
%o A332542 end
%o A332542 p A332542(100) # _Seiichi Manyama_, Feb 19 2020
%o A332542 (PARI) a(n) = my(k=1); while (sum(i=0, k, n+i) % (n+k+1), k++); k; \\ _Michel Marcus_, Aug 26 2021
%o A332542 (Python)
%o A332542 def a(n):
%o A332542     k, s = 1, 2*n+1
%o A332542     while s%(n+k+1) != 0: k += 1; s += n+k
%o A332542     return k
%o A332542 print([a(n) for n in range(3, 67)]) # _Michael S. Branicky_, Aug 26 2021
%Y A332542 Cf. A332543, A332544, A082183.
%Y A332542 See A332558-A332561 for a multiplicative analog.
%K A332542 nonn
%O A332542 3,1
%A A332542 _Scott R. Shannon_, Feb 18 2020