A234143 Numbers k such that triangular(k) - x and y - triangular(k) are both triangular numbers (A000217), where x is the nearest square below triangular(k), y is the nearest square above triangular(k).
1, 4, 5, 19, 22, 25, 40, 64, 85, 89, 110, 124, 127, 148, 263, 552, 688, 700, 705, 790, 1804, 2101, 4009, 4108, 8680, 11830, 15889, 22125, 23611, 23710, 27571, 32902, 34536, 39520, 47327, 62329, 68374, 98896, 100933, 112660, 137614, 137989, 138191, 159124, 205004
Offset: 1
Keywords
Examples
Triangular(4) = 4*5/2 = 10. The nearest squares above and below 10 are 9 and 16. Because both 10-9=1 and 16-10=6 are triangular numbers, 4 is in the sequence.
Programs
-
Mathematica
btnQ[n_]:=Module[{tr=(n(n+1))/2,x,y},x=Floor[Sqrt[tr]]^2;y=Ceiling[ Sqrt[ tr]]^2;!IntegerQ[Sqrt[tr]]&&AllTrue[{Sqrt[1+8(tr-x)],Sqrt[1+ 8(y-tr)]}, OddQ]]; Join[{1},Select[Range[205100],btnQ]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Aug 12 2020 *)
-
Python
import math def isTriangular(n): # OK for relatively small n n+=n sr = int(math.sqrt(n)) return (n==sr*(sr+1)) for n in range(1,264444): tn = n*(n+1)//2 r = int(math.sqrt(tn-1)) i = tn-r*r r = int(math.sqrt(tn)) j = (r+1)*(r+1)-tn if isTriangular(i) and isTriangular(j): print(str(n), end=',')
Extensions
Name corrected by Alex Ratushnyak, Jun 02 2016
Comments