OFFSET
1,2
LINKS
Donovan Johnson, Table of n, a(n) for n = 1..1000
Shyam Sunder Gupta Fascinating Triangular Numbers
EXAMPLE
a(4)=91: 91 is a triangular number and also a happy number as 9^2+1^2=82, 8^2+2^2=68, 6^2+8^2=100 and 1^2+0^2+0^2=1. So 91 is triangular happy number.
MATHEMATICA
Module[{nn=300, trnos, haps}, trnos=Accumulate[Range[nn]]; haps=Select[Range[ (nn(nn+1))/2], FixedPoint[ Total[IntegerDigits[#]^2]&, #, 10]==1&]; Intersection[ trnos, haps]] (* Harvey P. Dale, Aug 15 2014 *)
PROG
(Python)
from itertools import count, islice
def A076712_gen(): # generator of terms
for n in count(1):
m = t = n*(n+1)>>1
while m not in {1, 37, 58, 89, 145, 42, 20, 4, 16}:
m = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(m))
if m == 1:
yield t
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Shyam Sunder Gupta, Oct 26 2002
STATUS
approved