Contribution on Puzzlet #159

From:  Colin Elphick [celphick@netspace.net.au
]

Limit the search to triplets less than 1,000 (that is, to a maximum of 987, 988, 989).
*/
autodefine "off"
openconsole
color 15,0
int count, sum, i, product
sum = 0
count = 0
print "First   Second  Third   Triangular      Product"
print "i       i+1     i+2     Place           i(i+1)(i+2)"
print "======  ======  ======  ==============
==========="
' Start from -2 as Sloanes [http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A000217]
' lists 0 as a triangular number
for i = -2 to 997
product = i*(i+1)*(i+2)
while sum<product
count++
sum = sum + count
endwhile
if product = sum
print i,"\t",i+1,"\t",i+2,"\t",count,"\t\t",sum
endif
next i

locate 25,35 : print "Finished.",
do : until inkey\$<>""
closeconsole
end

/*
Output
First      Second   Third         Triangular             Product
i                   i+1         i+2               Place                  i(i+1)(i+2)
======  ======  ======  ==============  ===========
-2            -1                0                        0                              0
-1             0                1                        0                              0
0            1                 2                       0                              0
1             2                 3                       3                              6
4             5                 6                     15                         120
5             6                 7                     20                         210
9           10               11                    44                         990
56           57               58                  608                  185136
636        637             638              22736           258474216
*/

Colin,

Thanks for the input. Your answers are correct.  I never considered using 0 as a triangular number!  So I missed the first three solutions which you printed out.  I've mentioned this in the Puzzlet webpage and given you the credit.

Note that we both used different methods for detecting triangularity on this occasion as well.

Dave.