Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 3
    Am I missing something? Why not just do numbersArray[0] = 1; right after you allocate it? Commented Nov 16, 2011 at 11:07
  • <spoiler>the answer is larger than 5000. Commented Nov 16, 2011 at 11:08
  • I was thinking the same, numbersArray[0] = 1; will intialise the first 1 in the array to 1.. I think you overcomplicated the question Commented Nov 16, 2011 at 11:17
  • @tenfour: didn't think about that cause I didn't know of static contructors or that I could just use a method to return the initialized array :D Commented Nov 16, 2011 at 11:38
  • @SWeko: unless the number of triangle numbers needed for the solution is higher than about 1000000, the formula solution is still faster than the array solution xD Commented Nov 16, 2011 at 12:26