Project Euler #120: Square remainders

  • + 0 comments

    After figuring out (which is the most difficult part IMHO) the maximum remainder for a particular and , taking special care of , , we can obtain an solution making use of the formula of sum of cubes , sum of squares and sum of consecutive integers .

    I was unable to formally express how the maximum remainder can be found, and I suppose it would somehow begin with if is even and if is odd, and that any terms having as its factor could be ignored (therefore only look at the last or the last two terms depending on ), so we can pick that is best for what we want. The way I did it was to brute force some input and guess the pattern, though.

    I believe you should be looking at:

    1. odd : when , and
    2. even : when .