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.

A225844 Least k>0 such that triangular(n) + k*(k+1) is a triangular number.

This page as a plain text file.
%I A225844 #20 Nov 13 2024 15:12:08
%S A225844 2,1,3,5,7,2,11,13,5,17,19,3,6,25,27,9,31,33,35,4,9,41,8,45,47,10,14,
%T A225844 53,9,5,59,61,21,18,67,69,21,73,75,14,22,6,11,13,87,15,91,26,20,34,12,
%U A225844 101,26,105,30,7,20,33,115,117,119,34,21,125,37,129,29,133,14,137
%N A225844 Least k>0 such that triangular(n) + k*(k+1) is a triangular number.
%C A225844 For n>0, a(n) <= 2*n-1, because n*(n+1)/2 + (2*n-1)*2*n =  (9*n^2 - 3*n)/2 = 3*n*(3*n-1)/2 = triangular(3*n-1).
%C A225844 The subsequence with terms less than 2*n-1 begins: 2, 5, 3, 6, 9, 4, 9, 8, 10, 14, 9, 5, 21, 18, 21, 14, 22, 6, 11, 13, 15, ...
%C A225844 The sequence of n's such that a(n) < 2*n-1 begins: 5, 8, 11, 12, 15, 19, 20, 22, 25, 26, ...
%H A225844 Alois P. Heinz, <a href="/A225844/b225844.txt">Table of n, a(n) for n = 0..10000</a>
%p A225844 a:= proc(n) option remember; local w, k; w:= n*(n+1)/2;
%p A225844       for k while not issqr(8*(w+k*(k+1))+1) do od; k
%p A225844     end:
%p A225844 seq(a(n), n=0..69);  # _Alois P. Heinz_, Nov 13 2024
%t A225844 lktrno[n_]:=Module[{t=(n(n+1))/2,k=1},While[!IntegerQ[(Sqrt[ 8(t+k(k+1))+1]-1)/2],k++];k]; Array[lktrno,70,0] (* _Harvey P. Dale_, Aug 19 2014 *)
%o A225844 (Python)
%o A225844 def isTriangular(a):
%o A225844     sr = 1 << (a.bit_length() >> 1)
%o A225844     a += a
%o A225844     while a < sr*(sr+1):  sr>>=1
%o A225844     b = sr>>1
%o A225844     while b:
%o A225844       s = sr+b
%o A225844       if a >= s*(s+1):  sr = s
%o A225844       b>>=1
%o A225844     return (a==sr*(sr+1))
%o A225844 n = tn = 0
%o A225844 while 1:
%o A225844   for m in range(1, 1000000000):
%o A225844     if isTriangular(tn + m*(m+1)): break
%o A225844   print(m, end=', ')
%o A225844   n += 1
%o A225844   tn += n
%o A225844 (PARI) a(n)=for(k=1,2*n,t=n*(n+1)/2+k*(k+1);x=sqrtint(2*t);if(t==x*(x+1)/2,return(k))) /* from _Ralf Stephan_ */
%Y A225844 Cf. A000217, A002378, A082183, A088572.
%Y A225844 Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).
%K A225844 nonn
%O A225844 0,1
%A A225844 _Alex Ratushnyak_, May 17 2013