Hi,

I am trying to work out a formula to tell you how many squares there are no a chessboard. I want to write the formula in a way that you could work it out for any size grid.

The formula for a chessboard is x=8²+7²+6²+5²+4²+3²+2²+1².

Is there a function similar to Factorial but for addition not multiplication? This is so I could express the formula in the format of x=(n²)! (replacing the factorial function for an appropriate one)?

Any help would be greatly appreciated, as I am rusty on my mathematics and I'm trying to help my son with his maths project!

PS: I have managed to write a program to work out the answer in the following, which loops until it has added the square of n until n is equal to 1. However, I don't think the maths teacher would be impressed with this, as I know she doesn't approve of computers doing the work for you!

2. Hello, danielmegson!

I am trying to work out a formula for how many squares there are on a chessboard.
I want to write the formula in a way that you could work it out for any size grid.

The formula for a chessboard is: . $x \:=\: 1^2+2^2+3^2+4^2+5^2+6^2+7^2+8^2$
There is a formula for the sum of the first $n$ squares: . $S_n \;=\;\frac{n(n+1)(2n+1)}{6}$

For $n = 8\!:\;\;S_8 \;=\;\frac{(8)(9)(17)}{6} \;=\;204$

The derivation of that formula takes quite a bit of algebra.
. . If you're interested, I can show it to you.
.

3. FANTASTIC! SPOT ON! Thanks for the help! Any derivatives of this would be helpful as well, but if it's a lot of work to yourself please do not worry - you've been helpful enough!

4. Hello again, Daniel!

The derivation is not difficult, but it takes a number of steps.

Consider the first few sums:

. . $\begin{array}{ccc}1^2 &=& 1 \\ 1^2+2^2 &=& 5 \\ 1^2+2^2+3^2 &=& 14 \\ 1^2+2^2+3^2+4^2 &=& 30 \\ 1^2+2^3+3^2+\hdots + 5^2 &=& 55 \\ 1^2+2^2+3^2 + \hdots + 6^2 &=&91 \\ 1^2+2^3+3^2+\hdots+7^2 &=& 140 \end{array}$

We want a function $f(n)$ which generates these values.

Take the difference of consecutive pairs of numbers.
Then take the difference of the differences, and so on.

$\begin{array}{ccccccccccccc}
\text{Sequence} & 1 && 5 && 14 && 30 && 55 && 91 \\
\text{1st diff.} && 4 && 9 && 16 && 25 && 36 \\
\text{2nd diff.} &&& 5 && 7 && 9 && 11 \\
\text{3rd diff.} &&&&2 && 2 && 2 \end{array}$

Since the 3rd differences are constant,
. . the function is of the 3rd degree . . . a cubic.

The general cubic has the form: . $f(n) \:=\:an^3 + bn^2 + cn + d$

Use the first four terms of our sequence:

$\begin{array}{ccccc}
f(1)\:=\:1\!: & a + b + c + d &=& 1 & [1] \\
f(2)\:=\:5\!: & 8a + 4b + 2c + d &=& 5 & [2] \\
f(3) \:=\:14\!: & 27a + 9b + 3c + d &=& 14 & [3] \\
f(4)\:=\:30\!: & 64a + 16b + 4c + d &=& 30 & [4] \end{array}$

$\begin{array}{ccccc}
\text{Subtract [2] - [1]:} & 7a + 3b + c &=& 4 & [5] \\
\text{Subtract [3] - [2]:} & 19a + 5b + c &=& 9 & [6] \\
\text{Subtract [4] - [3]:} & 37a + 7b + c &=& 16 & [7] \end{array}$

$\begin{array}{ccccc}
\text{Subtract [6] - [5]:} & 12a + 2b &=& 5 & [8] \\
\text{Subtract [7] - [6]:} & 18a + 2b &=& 7 &[9] \end{array}$

$\begin{array}{ccccccc}
\text{Subtract [9] - [8]:} & 6a \:=\:2 & \Rightarrow &\boxed{ a \:=\:\tfrac{1}{3}} \end{array}$

$\begin{array}{cccccccc}\text{Substitute into [8]:} & 12\left(\tfrac{1}{3}\right) + 2b \;=\;5 & \Rightarrow &\boxed{ b \:=\:\tfrac{1}{2}} \end{array}$

$\begin{array}{ccccccc}\text{Substitute into [5]:} & 7\left(\tfrac{1}{3}\right) + 3\left(\tfrac{1}{2}\right) + c \:=\:4 & \Rightarrow &\boxed{ c \:=\:\tfrac{1}{6}} \end{array}$

$\begin{array}{cccccc}\text{Substitute into [1]:} & \tfrac{1}{3} + \tfrac{1}{2} + \tfrac{1}{6} + d \:=\:1 & \Rightarrow & \boxed{d \:=\:0} \end{array}$

Therefore: . $f(n) \;=\;\tfrac{1}{3}n^3 + \tfrac{1}{2}n^2 + \tfrac{1}{6}n \quad\Rightarrow\quad\boxed{ f(n) \;=\;\frac{n(n+1)(2n+1)}{6}}$