All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Some Triangles Sum 2014 (Posted on 2014-08-12)
Determine all possible sequences of consecutive triangular numbers whose sum is precisely 2014.

Extra Challenge: A non computer program based method.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 2 of 5 |
DefDbl A-Z
Dim crlf\$

ChDir "C:\Program Files (x86)\DevStudio\VB\projects\flooble"
Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents

firstTri = 1: lastTri = 1: Sum = 1

Do
If Sum = 2014 Then
Text1.Text = Text1.Text & firstTri & Str(lastTri) & "     "
Text1.Text = Text1.Text & Str(isTri(firstTri)) & Str(isTri(lastTri)) & "     "
For i = isTri(firstTri) To isTri(lastTri)
Text1.Text = Text1.Text & Str(triNum(i))
Next
Text1.Text = Text1.Text & crlf
DoEvents
ElseIf Sum < 2014 Then
Else
Sum = Sum - firstTri
End If

Loop Until firstTri > 2014

Text1.Text = Text1.Text & crlf & firstTri & Str(lastTri) & " done"
End Sub

Function isTri(t)
n = Int(Sqr(t * 2))
np = n + 1
If n * np = 2 * t Then isTri = n Else isTri = 0
End Function

Function triNum(i)
triNum = i * (i + 1) / 2
End Function

finds only two sequences of triangular numbers that add to 2014:

`First &	   Tr(#)      All the triangular numbers in the sequnce.last nos.  first &	    last10 253      4 22      10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 25378 276      12 23      78 91 105 120 136 153 171 190 210 231 253 276`

So, the 4th through 22 triangular numbers (10 through 253) add up to 2014 as do the 12th through 23rd (78 through 276).

 Posted by Charlie on 2014-08-12 17:10:24

 Search: Search body:
Forums (0)