I saw an example of creative thinking recently to add quickly the numbers 1 to 10, or 1 to 100. The method was quick but not necessarily intuitive - which is part of the point.

I started thinking about this to see if I could adapt the method to add the even numbers between say 1 and 300. I did the mental arithmetic fairly quickly and then checked my working with pen and paper afterwards.

There have been some interesting tester challenges doing the rounds recently, and I thought that a thinking challenge was in order.

So, the challenge is to add the even numbers (2, 4, 6,...) from 1 to 300.

Bonus points if you can do it in less than 30 seconds! Less than 10 seconds if using a calculator. (I'm not counting alternative thinking time here - that I'll leave to you to work on.)

If you want to post a comment with the answer here then you'll need to show your thinking!

*(I'll delay comment publication a few days in case there's any latecomers that wants to try it - without being tempted by the comments.)*

There will be a follow-up post - where I identify the book and some other things I've learnt from it.

I knew there had to be a simple formula (pattern) to calculate this so I wrote out the even numbers from 2 - 10 on a sheet of paper along with the running totals. So I knew that 2+4+6+8+10 = 30. I had a hunch that somehow the pattern would be related to the place in the series (10 is the fifth number in the series of even numbers from 2-10) and that's when I saw that 30 = 5*5+5. I checked the pattern and here you have it!

ReplyDeletey = (x/2)^2 + (x/2)

y = (300/2)^2 + (300/2)

y = 150^2 + 150

y = 22,500 + 150

y = 22,650

(n^2 + 2n) / 4, correct?

ReplyDeleteA take on the (n^2 + n)/2 trick??

Seems to me that's basically the sum of 2 * (Sum of all numbers from 1-150) Sum of 1-150 is 11325, times 2 is 22650 the real crux is how to get at 1-150 quickly without the aid of a calculator or in my case Excel (which yeah tentatively might be cheating I was trying to verify my theorem without adding in my head.

ReplyDelete300 + 2 is 302

ReplyDelete298 + 4 is 302 ...

So, the total ought to be 302*75 (the number of times you have to iterate this) ... 22,650

Hope I got it right!

I can't even think about doing a challenge that involves doing math. Sorry! I like the idea of promoting creative thinking though.

ReplyDeleteWell I'm not that good in math, but I'll remember some basics from university so I try it:

ReplyDeleteWe want to know the sum of all even numbers from 1 to 300. So our summation is 1 (k) to 150(n) = 2*k which we can change to n*(n+1) -> 150* (150 + 1) = 22650.

Hopefully I'm right ;)

Step 1:

ReplyDeleteThere are 150 even numbers.

Step 2:

Find pairs which together form 300;

2 + 298 = 300

4 + 296 = 300

6 + 294 = 300

etc

There are 74 such pairs; 74 * 300 = 22200

Step 3:

The numbers 150 and 300 are not used yet; 22200 + 300 + 150 = 22650.

This exercise took me 1-2 minutes incl checking the answer in Excel.

Seems like it is 2 times the sum of the integers 1 to 150. The sum of the integers 1 to N is N(N+1)/2, so the answer would be 150 * 151.

ReplyDeleteHi Simon,

ReplyDeleteI could not do it in less than 30 seconds. It took me roughly 2 mins to do it manually - I guess. Confirming if my answer was correct using the formula took longer time. I am aware that there are many shortcuts to math in Vedic mathematics, but most of them fail my memory at this point.

Manual Method (Should I call it Sapient :-))

---------------------------------------------

I looked for patterns in the sum of even numbers between 1-10, 11-20, 21-30 and so on.

2+4+6+8+10 = 30

12+14+16+18+20 = 80

22+24+26+28+30 = 130

32+34+36+38+40 = 180

Hence the pattern finally looked like this:

30

80

130

180

230

280

330

380

430

480

530

580

630

680

730

780

830

880

930

980

1030

1080

1130

1180

1230

1280

1330

1380

1430

1480

The total sum is 22650

While calculating this manually, I was pretty sure that Progressions (Arithmetic/Harmonic/Geometric) could solve this problem lot more faster using an easy formula. After browsing through Wikipedia to dust my memory on Arithmetic progressions, I came to believe that I was referring to Arithmetic Series and calling it Arithmetic Progression.

Formula Method

--------------

Lemme now verify if my answer is same as the one the formula says. Now you ask which formula. Hmm, I need to figure out. I have forgotten the formulae years ago as I don't need to give crappy exams in maths anymore :D. Knowing a lot of math does help testers in many ways.

Formula for Arithmetic Series gives the Sum of all numbers between 1 to 300

ie. 300x(2+300)/2 = 45300

How do I extract the even numbers alone. There are 150 even numbers and 150 odd numbers considering the numbers between 1 and 300.

2+4+6+8+.......................298+300 = 2*(1+2+3+.........+150) = 2*[150(1+150)/2]

The total sum using the formula is 22650.

All that I did above is to replace the series (1+2+3+......+150) using the Arithmetic Series formula.

So my manual answer is inline with the answer that the formula says. Am I blindly following the formula. Nah! I used the formula as my oracle ;)

Good Exercise doing math after a long time,

Thanks,

Parimala Shankaraiah