# Ada Lovelace, Bernoulli and the Gauss Schoolboy Problem

Ada Lovelace, Bernoulli and the Gauss

Schoolboy Problem

### Introduction to Ada Lovelace

Introduction to Ada Lovelace

Ada Lovelace was an English mathematician and writer. She is chiefly known for her work on Charles Babbage’s early

mechanical general-purpose computer, the Analytical Engine. She is considered the first female computer programmer

due to her work on Bernoulli numbers. Read more about Ada Lovelace in Stephen Wolfram’s blog post,

Untangling the Tale

of Ada Lovelace

.### The Gauss Schoolboy Problem

The Gauss Schoolboy Problem

There’s a well-known story about the famous German mathematician Carl Friedrich Gauss. As a young schoolboy, he was

tasked with adding the first 100 integers, i.e. what is 1 + 2 + 3 + 4 + ... + 98 + 99 + 100? (The answer is 5,050.) Gauss reportedly

produced the correct answer within seconds.

How did he do this?

The trick is to pair the numbers 1 + 100, 2 + 99, 3 + 98..., 50 + 51 to get 50 x 51 = 5,050.

Can we easily calculate the sum of the squares of the numbers 1 to 100 today? Yes! Using computers and

programming, there are several ways to do so.

### Introduction to the Wolfram Language

Introduction to the Wolfram Language

Using the built-in functions available in the

Wolfram Language

, it is elementary to calculate this quantity. In fact, there is more than one way to do it using Wolfram Language technology. Before you can explore that, this section will provide an

introduction to the Wolfram Language.

Let’s try to do something simple first.

Click the line below and press Shift + Enter ( + ).

↓

In[]:=

1+2+3

You should have gotten the output 6.

#### Functions

Functions

All calculations in

Mathematica

are done by calling functions.

You can think of each function as a box. Into each box we put arguments, and then the box spits out a result.

#### Evaluate the Following Examples

Evaluate the Following Examples

(Click next to the inputs below, hold down and press .)

↓

In[]:=

Divide[65,5]

In[]:=

Expand[(a+b)^2]

### Introduction to Bernoulli Numbers

Introduction to Bernoulli Numbers

Let’s try a simpler version of the Gauss schoolboy problem: calculating the sum of the first two integers, i.e. 1 + 2, and then

increasing the sum steadily.