# Bean Counting

As the rest of the class frantically scribbled, ten year old Carl Gauss came to the front and presented his slate to the teacher. The teacher was furious: he had only just set the problem and had expected to have a whole lesson where he could just snooze. The problem involved adding up all the numbers from 1 to 100: that normally took the kids 30 or 40 minutes, not seconds - back then in 1787 there weren't even calculators just slates to write on, and even with a calculator it would take a while to work out the answer. Surely Gauss could not have worked it out so quickly...but his answer was right: 5050...and remarkably he hadn't needed any working. He had just written down the answer.

## Algorithms: the rules of the game

How had Gauss done it? By lateral thinking. He had attacked the problem in a different way, to everyone else, seen a pattern and come up with a different route to the answer. Gauss is now hailed as a great Mathematician but in that lesson he was also dabbling in computer science long before computers were invented. At the core of computer science is the idea of algorithms - rules you can follow to complete some task...whether to recognize a pick-pocket in a CCTV picture, fly a plane or calculate an answer to a teacher's question. There can be many algorithms for the same task some faster than others. What Gauss had done was come up with a mathematical equation that allowed him to invent a faster algorithm than anyone else had previously thought of. It doesn't really matter whether the algorithm is to be followed by a person or a computer, so even though computers weren't invented, he was doing computer science.

Once you know Gauss's trick - the fast algorithm - you can solve the problem as fast as he did