Happy numbers: Difference between revisions

Content deleted Content added
Tikkanz (talk | contribs)
→‎{{header|J}}: add alternative formulation
Line 526:
past = []
while True:
total = sum([int(i)**2 for i in str(n)])
if total == 1 or total in past: return not total in past
n = return total; not in past.append(total)
n = total
past.append(total)
>>> [x for x in range(1,500) if happy(x)][:8]
</lang>