Home > math > Sum of Consecutive Integers: Update 1

Sum of Consecutive Integers: Update 1

October 19th, 2009 Mr. H Leave a comment Go to comments

This is a follow-up to my response to JD2718′s Puzzle on Sum of Consecutive Integers

At end of Sum of Consecutive Integers I said I’d be posting the tool I used to get to my solution. I can’t find a better name for now so it’s temporarily just SumConInt. You can find it under Math Tools in the future.

Use the presets to go through some of the numbers that I tried as I looked for a pattern. There’s a logic to the sequence of presets that is listed. Each one clarifying the underlying structure just a little bit more. I hope it’ll lead you to the same solution that I found.

The script is NOT efficient. I haven’t spent time optimizing it. It was a one-off kind of thing that I used to test my conjectures. I may spend time cleaning up the code in the future. A supervisor warned me that having embarrassing/clumsy code online was one way to not get hired as a programmer. You may see random comments and variables that aren’t used. The script comes with no guarantees expressed or implied.

After you’re done playing with presets, try using some batch commands and some individual number tests. I haven’t spent time doing error checking on input so don’t test outlandish values unless you can handle crashes well. The “calculate up to” should be used for numbers less than 100. Use it with caution.

I will probably have a follow-up post with a solution in a few days.

Sum of Consecutive Integers
Sum of Consecutive Integers: UPDATE 1
Sum of Consecutive Integers: UPDATE 2

Categories: math Tags: , , , ,
  1. November 6th, 2009 at 02:09 | #1

    This is the same as the problem I saw over here
    http://uva.onlinejudge.org/external/102/10290.html
    I did it just a month ago for my ACM-ICPC training. The solution was found by an accident. My teammate found a formula for odd cases, and I guessed the formula for even cases. It actually worked. xD

  1. November 8th, 2009 at 14:42 | #1

Spam protection by WP Captcha-Free