"be consistent"  
PerlMonks 
Re: Triangle Numbers Revisitedby hv (Parson) 
on Oct 14, 2004 at 12:47 UTC ( #399183=note: print w/ replies, xml )  Need Help?? 
I'm not sure quite how you might take advantage of it for optimisation, but the possible decompositions are restricted by the mod 3 equivalences. That is: so if we split the T_n sequence into A_n (== 0) and B_n (== 1) the possible decompositions are restricted such that:
You can get similar restrictions by considering other prime moduli, but 3 is likely to be the most beneficial because it has a shorter than possible cycle in T_n. Also, a word of warning on your p_tri() routine  the final result relies on comparing a floating point number for equality, normally considered a bad idea. It would be preferable to do the test instead by calculating from $t back up to the last known integer value, something like:
Hugo
In Section
Seekers of Perl Wisdom

