#MathEd – Math for My Nephew

A while ago I was asked to provide some resources I use to teach math for my nephew (well, nephew-in-law). I decided to gather them together into a blog post and thus get a two-fer.


Mathematical Association of America (http://www.maa.org/) – Their stated mission is “to advance the mathematical sciences, especially at the collegiate level.” Membership is open to students and teachers (K-12 and college), starting at $35/year (student with proof of status) and going up to $249/year (Member Plus). I’m a member and for me the real value of membership is access to a wide range of publications plus discounts on books, both e-book and printed. (Disclaimer: I currently write book reviews for the MAA web site but I am not compensated.) You can follow them on Twitter at @maanow and on Facebook as maanews.

National Council of Teachers of Mathematics (http://www.nctm.org/) – Like the MAA, the NCTM offers memberships to students, teachers (primary through college) and to organizations. They also offer the option of an ‘e-membership’ at each level for a slight discount. Membership annual dues range from $44 (Student and Emeritus) to $144 (Full Individual Membership). Membership gives you access to a host of instructional materials, NCTM’s ‘e-standards’ and NCTM’s E-Seminars, 60 minute on-demand video presentations on a variety of math education topics. You can follow them on Twitter at @NCTM or on Facebook as NCTM Illuminations.


Math with Bad Drawings – This is one of my favorite sites. Ben Orlin provides an entertaining and educational view of math from a teachers perspective. The title comes from each post being illustrated by a series of stick drawings on a whiteboard. I wrote a review of his site here. I’ve used some of his posts as jumping-off points for discussions in my math class. You can follow Ben on Twitter as @benorlin. He’s also on Facebook but doesn’t appear to be too active.

MathBabe – Cathy O’Neil is a former Wall Street quantitative analyst who left for the wilds of higher education. She mainly blogs about Big Data and math education in higher ed. I wrote a review of her site here. A smart, interesting, fun site. You can also follow Cathy on Twitter.

Finding Ways to Nguyen Students Over – Fawn Nguyen is a California math teacher who has one of the best math blogs I’ve seen for primary and secondary educators. She clearly works hard to present math to her students in innovative and entertaining ways and she shares these techniques on her blog. (I wrote a review of her site here.) However, the real hidden gems of her site for educators are the affiliated sites like Visual Patterns, Math Munch and Would You Rather. These sites are a treasure trove of fun math problems and exercises you can share with your students or work on your own.

The NRICH Project – Not a blog per se, but The NRICH Project was started by the University of Cambridge, according to their “About” page:

“to enrich the mathematical experiences of all learners. To support this aim, members of the NRICH team work in a wide range of capacities, including providing professional development for teachers wishing to embed rich mathematical tasks into everyday classroom practice.”

(More here.) The content is divided into material for teachers and students. Each category is further divided into primary and secondary education. The idea is to present tasks that target multiple learning styles. These are known as “rich tasks” and you can get more information about them from this article.  Teaching materials are printable and downloadable for ease of use. You can also follow the NRICH project on Twitter  and on Facebook. You can sign up on their mailing list to get updates. They also provide a guide for parents and caregivers.

Project Euler – Also not a blog but a cool site for more advanced math fans. (Yes, there are some of us out there.) It’s a collection of almost 500 math problems, some of which may require basic programming skills. Each problem builds on insights gained solving previous problems so I advise doing them in order. I’ve posted a few of the problems on my site. Working on the problems presents interesting insights and is definitely mind-expanding.


NumberPhile – This is a nice resource of short, entertaining videos about specific math concepts. I do a short segment at the beginning of my classes called “Math Minute” and I’ve used several of these as inspiration for material. You can also follow them on Twitter and Facebook.

ComputerPhile – Not strictly related to math, but computer science is based on math. Similar to NumberPhile, ComputerPhile provides short videos about topics like undecidability, cryptography and how computers use math to do animation. You can follow them on Twitter or on Facebook.

I’m always looking for good math resources, both for my classroom and this blog. If you have any interesting leads, post them in comments!

#WeHateMath Project Euler 11 – Largest Product in a Grid

In the 20 X 20 grid below, four numbers along a diagonal line have been marked in red.


The product of these numbers is 26 63 78 14 = 1788696.

What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 2020 grid?



This is the first Project Euler problem that has personally offended me. That may seem strange but it’s because this is at it’s core an arithmetic problem, not math. At first glance, it seems similar to Euler problem 8, but it’s really a brute-force, grind-out-every-product-and-compare-them, ugly, arithmetic problem. So while I would have preferred a more elegant solution (a scalpel instead of a hammer, as it were), I went with the ugly one.

The perfect programming language for ugly, brute-force hammer solutions is C, so that’s what I used. (I considered Fortran, which is actually better for brute-force math and arithmetic problems but the last time I used it was in 1977).

So when I ground out the answer, here’s what I got:

MacPro15:WeHateMath tsinclair$ time ./Project_Euler11


So it only took about 3-thousandths of a second to get my answer, but I’m still annoyed.

#WeHateMath Project Euler 10 – Summation of Primes

Summation of primes

Problem 10

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

We’ve spoken about primes before but this problem is different. First of all, it seems pretty straightforward. We’re adding up a list of numbers. Granted, we have to generate the list of numbers first but generating a list of primes is not unknown technology. (Like any nerd, I let a computer do the hard work).

The question is (as it is with all of these problems), why do it?  What’s the point? That’s what I had to ponder for a while. So I decided to let my computer grind through a few possibilities. Using a combination of a spreadsheet and some computer code (and there’s no reasonable way to do this without some programming skills), I poked at some numbers.

One of the first things I discovered was that (no surprise) the sums get big pretty quickly. I started by asking Wolfram Alpha to do prime sums for me. It worked fine for 10, 100, 1000 and up to 1000000. But when I asked for the sum of primes less than 2,000,000 it crapped out on me. You see, Wolfram Alpha has built-in limits on how much processing time you can use.

Okay, you have my interest now.

I poked around and found some program code that did sums of primes, loaded it into XCode, compiled and ran it. At first I used it to check the numbers that Wolfram Alpha had given me (no harm in checking). Of course, as the numbers got bigger, the processing took longer and longer. I decided to shorten things by asking for the sum of primes between 1,000,000 and 2,000,000 (since I already had the sum for 1,000,000). I dumped it into my spreadsheet and made a table:



Sum of Primes

Sum of N

Diff(N, Sum_of_Primes)

Diff(N, Sum_of_N)










































Just for fun, I added a column of straightforward sums plus differences. (You never know what relationships will pop up.) I also ran my prime summing program with a timer and here are the results:


Enter min range: 2
Enter max range: 2000000
Sum of prime numbers is: 142913828922


In human-speak, this means that the calculation took almost twenty minutes of ‘real’ time (as in wall-clock time) and about two-thirds of a second of computing time. Just out of curiosity, I ran the same program but just for the primes between one million and two million:


Enter min range: 1000000
Enter max range: 2000000
Sum of prime numbers is: 105363426899


Interestingly enough, it took almost the same amount of ‘real’ time but about a third of the computing time. Just for fun, I wondered how much time it would take to do sum of primes up to 1 million:


Enter min range: 2
Enter max range: 1000000
Sum of prime numbers is: 37550402023


Well, about one-third of ‘real’ time and a bit more computing time. The latter was to be expected but the former isn’t.

In any event, I’m still not sure about the point to this problem. If I figure it out, I’ll post an update.

#WeHateMath Project Euler 9 – Pythagorean Triplets

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,

For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.

Find the product abc.

Let’s get the problem part out of the way first. It turns out to be pretty easy to generate Pythagorean Triplets (sometimes called Pythagorean triples):

Pick two positive integers, m and n, ,where m < n. Generate your three values like so:

Of course, doing this by hand is annoying and this is just the sort of thing for which spreadsheets were made. I set up the formulas and then starting fiddling with values of m and n and it just took a few tries to range in on the answer:



















a^2 plus b^2




Readers know by now that the point of the Project Euler posts is not to simply get the answer to the problem but to figure out the point of the problem. In this case, that’s not obvious. Though Pythagorean Triples are a surprisingly hot topic of discussion among mathematicians if my casual research is anything to go by. I even found a paper documenting a new way to generate triples that suggests an interesting application of the math to cryptology. It’s especially surprising when you consider that these triples have been around for over 2000 years.

The classic Pythagorean triples are (3, 4, 5) and (5, 12, 13). You can generate new triples by using multiples of each element. In our answer above, (375, 200, 425) is a multiple of (3, 4, 5). There are others, however. For example (4, 3, 5) is also a valid triplet but can’t be generated by the traditional methods.

Pythagorean Triples are connected to both Fibonacci numbers and primes, which we’ve discussed previously.. The two classic triples each have Fibonacci values as two of the three values. In addition, up to two of the legs can be prime numbers but because at least one of the legs must be even, there is no triple where all three elements are primes.

This is a great example of pure mathematics that may (or may not) someday find some practical application. I view mathematics as a way to perform experiments on the universe, but unlike traditional laboratory science, my lab bench is conveniently located between my ears. So the next time someone tells you that studying math is impractical, remind them:

#WeHateMath Project Euler 8 – Math Makes Everything Better

Find the greatest product of five consecutive digits in the 1000-digit number.


At first glance this appears to be arithmetic which, as we all know, is boring and mechanical and completely beneath us as humans. Well, actually, at first glance the part of our brains that does arithmetic (you know, the boring part) sees this awful number and just wants to shut down. Since I knew it had to be more than just arithmetic, I tucked it in the back of my mind to ferment a bit before tackling it again.

After a bit of thought, I can see the trick here. The problem statement refers to a 1000-digit number but we’re supposed to deal with individual sets of digits. So we can use math to make this more interesting (since math makes everything better) and simply regard this as a string of 1000 digits.

How does this help? First of all, any string of digits with a zero in it we can disregard. In fact, we can discard any ten consecutive digits that have a zero in the middle since any five digit sequence will multiply out to zero. So we look for digits with this pattern:


Let’s take another look at our number, clearing out digits within four positions of any zero:


Okay, I’ve eliminated all strings of digits whose product will be zero so our new string of digits becomes:


(I could have written a script to do this for me but pattern-matching is part of my evolution so I can do it myself without much trouble.)

This is a much more manageable number (still 389 digits long, though) but if we’re ultimately going to be doing arithmetic (and it looks like we’ll have to eventually) we have to think about having a machine do the work and that involves explaining the task to a machine in a way that it can understand. But this brings us to a question:

Do we really have to do any arithmetic at all?

A bit of thought tells us that we may be able to avoid arithmetic after all.  Here’s the logic:

Start scanning the string of digits and split off each set of five. For example, if our string was:


We would pull out the substrings:





Now, remember, I don’t really want to any arithmetic if I can help it so I do a bit of math thinking and rearrange the numbers in sorted order:

Original           Sorted

73167                77631

31671                76311

16717                77611

67176               77661

I can multiply numbers in any order I want so rearranging the digits won’t change the outcome. However, by sorting numerically, the number with the largest magnitude will automatically give me the largest product. 77661 is the largest number in my sequence here but let’s test my hypothesis just to check my thinking:

Original                     Sorted               Product

73167                          77631                882

31671                          76311                 126

16717                          77611                294

67176                         77661                 1764

Sorting has the added benefit of letting us eliminate strings that have the same digits (and thus the same product). So I only need to find the largest five digit number (after sorting) and then get the product of those five digits. I have now knocked my job down to doing a single multiplication and I bet I can get my computer to do even that little job for me if I’m feeling particularly lazy.

So I just whipped up a quick script to dump out 386 separate five digit strings of digits and sort each set of strings numerically. Then I copied and pasted the output into a spreadsheet and did a quick numerical sort to find the largest numerical quantity. Here is my result:


It’s then a simple matter of using my hand-dandy calculator and determining the product, which is 10,206.

So we took a problem that looked like it would require almost 1000 arithmetic operations and knocked it down to a single calculation with just a bit of thought about the conditions of the problem.

If anyone is interested, I’ve posted my script here.

See, math makes everything better!

Project Euler #7 – Prime Mysteries of the Mind

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10,001st prime number?

“Mathematicians have tried in vain to this day to discover some order in the sequence of prime numbers, and we have reason to believe that it is a mystery into which the mind will never penetrate.”

Leonard Euler, in G. Simmons, Calculus Gems, McGraw-Hill, New York, 1992

According to Wolfram Alpha, the 10,001st prime number is 104,743. Now (as always) we must ask,“what’s the point?”

To be fair, it’s all well and good that we have these fancy computers that we can just ask for the answer, but let’s dig deeper and get more background on what’s so hot about prime numbers. As the quote above from noted brainiac Leonard Euler indicates, prime numbers are a mystery wrapped in an enigma covered in secret sauce.

We’ve talked about prime numbers before and how they’re used to secure the Internet. But the ancient Greeks studied primes and they didn’t even have smartphones (at least, I don’t think so….nope, they didn’t). One thing to note about primes is that they are devilishly hard to predict. I mean, if I gave you a sequence of even numbers and asked you to determine what the next number in series would be, that would be a no-brainer. However, if I gave you a sequence of prime numbers, that would involve a lot more work. Factoring numbers (our main test for primality) is one of those problems that are known as NP (Non-Polynomial). In plain talk, there are no shortcuts to the answer. But what if we asked the question a different way?

That’s what a man named Eratosthenes did. Prime numbers were as weirdly fascinating to the ancient Greeks as they are to us and Eratosthenes was a noted mathematician of the day. Just to give you a sense of the man, he was also a music theorist, poet, astronomer, invented geography and in his spare time was the chief librarian of the greatest collection of ancient wisdom of his times, the Library at Alexandria, not to mention being the first person to calculate the circumference of the ENTIRE FREAKING PLANET.

Frankly, it’s all I can do to get through my daily Twitter feed before I feel the need for a lie down. But I digress.

Anyway, while his fellow mathematicians were mapping out primes the hard way, Eratosthenes asked the question, “How do we find the prime numbers in a given sequence of numbers?”. One day he had a revelation. He already knew how to find if a number was prime the hard way. But, he reasoned, any multiple of a prime is by definition not prime.
Here’s how it worked. Consider the first ten digits (1 is crossed off since it is neither prime or non-prime).

X 2 3 4 5 6 7 8 9 10

Our first prime is 2, so we cross off all multiples of 2.

X 2 3 X 5 X 7 X 9 X

3 is also a prime, so we cross off all multiples of 3.

X 2 3 X 5 7 X X X

We’ve finished the sequence and all we have left are the primes 2, 3, 5 and 7. We can do this for any sequence of numbers, filtering out the primes like grains of sand through a sieve. Hence the name for this technique, which has survived to this day – the Sieve of Eratosthenes. As a side benefit, this reduces the effort of finding primes to simple arithmetic, making it perfect for handing off to a machine. (In fact, one of the first programming problems they give students is to code up their version of the Sieve.)

One more thought about primes and this one’s a bit more relevant to the Project Euler problem above. If we map out the Nth primes for N in {1, 11, 101, 1001 and 10,001}, we get:



Nth Prime






















If we look at the gaps we can see that, as the sequence numbers get bigger, the gaps between primes get bigger. It’s even more obvious when we graph out the first 100 primes:

This actually makes intuitive sense. Larger numbers have more possible factors so are less likely to be prime. (Give that a moment to sink in.) This is an illustration of what is known as the prime number theorem. Here’s the idea:

  • Pick a large positive integer. Call it N.

  • Pick a random integer between 1 and N. Call it R.

The probability of R being random are roughly 1/ln(N). (one divided by the natural logarithm of N). So the bigger N is, the smaller the odds of R being prime. In other words, as we see in our graph above, the gaps between prime numbers get bigger as our numbers get bigger. Like people, prime numbers are easier to understand when we look at them in groups.

“Some order begins to emerge from this chaos when the primes are considered not in their individuality but in the aggregate; one considers the social statistics of the primes and not the eccentricities of the individuals.”

P.J. Davis and R. Hersh, The Mathematical Experience, Chapter 5


Project Euler #6 – Hip to be Square

The sum of the squares of the first ten natural numbers is,

12 + 22 + … + 102 = 385

The square of the sum of the first ten natural numbers is,

(1 + 2 + … + 10)2 = 552 = 3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 – 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

I’m very well acquainted too with matters mathematical,

I understand equations, both the simple and quadratical,

About binomial theorem I’m teeming with a lot of news–

With many cheerful facts about the square of the hypotenuse.

Gilbert & Sullivan, “The Pirates of Penzance”

At first glance this seems to be just arithmetic which is kind of insulting. As we’ve discussed, arithmetic is only about getting to an answer and that’s the kind of boring stuff that is only fit for machine work. Clearly there must be something else going on here or I’m just going to be terribly annoyed. So let’s take a look at the math (which is much more interesting) behind sum of squares and then see if we can figure out a cunning way of getting our answer without all of that boring arithmetic. It turns out that there are at least two interesting things about the sum of squares.

The most interesting (to me, at least, dork that I am) has to do with storing cannonballs.

Let me explain.

Imagine you’re on vacation and you visit an historical site and you come across a cannon, complete with ammunition:

Photo courtesy of Hans Braxmeier (via Pixabay)

Pretty standard stuff, but what if you wanted to figure out how many cannonballs are in that pile? Better still, could you do it without actually counting any cannonballs? It turns out that you can. Note that the top of the pile has one cannonball, the layer underneath has four and so on. In other words, if we count the layers from the top down, our four layer pile here has:

12 + 22 +32 + 42 or 30 cannonballs (1 + 4 + 9 + 16). In other words, our pile of cannonballs can be expressed as a sum of squares. So we don’t need X-ray vision, we just count the number of layers in the pile and do a little arithmetic. Not bad! Note that this only works if the pile is in the shape of a square based pyramid, hence the name square pyramidal numbers for the number sequence. Of course, if there was an easy way to calculate the sum of squares than by doing all that boring arithmetic that would be better but we’ll talk more about that in a bit.

Okay, let’s look at an example that’s a bit more real world and not so much ‘Battle of Liechtenstein’. Sum of squares is more often used in statistics to analyze a set of data points. First let’s get the boring arithmetic over with so we can get on with our lives. Fortunately I recently learned about a programming language called Haskell that lets me do stuff like this pretty easily.

let x = sum(map (^2) [1..100]) (sum of squares of 1 to 100)
print x
let y = foldl (+) 0 [1..100] (sum of 1 to 100)
print y
25502500 (square of the sum of 1 to 100)

When mathematician Carl Friedrich Gauss was eight years old (in 1785, by the way), his teacher asked the class to give the sum of the numbers 1 to 100. The idea was to keep the little buggers busy and quiet for at least a few minutes but Carl piped up almost immediately with the answer 5050. Not only did he do the sum in his head, he was able to prove his answer was correct.

Here’s how he did it (in his head, by the way):

Picture the numbers 1 to 100 in a line:

1 2 3 4 5 6 7 … 100

Now picture another row, with the same digits arranged in the opposite order:

100 … 7 6 5 4 3 2 1

Add the two rows together:

1 + 100 = 101, 2 + 99 = 101, 3 + 98 = 101 ...

Since there are 100 pairs of numbers, each adding up to 101, then the total sum is 101 x 100 or 10100. But the sum of the original sequence (which is what we wanted all along) is half of that or 5050. Sometimes you don’t need a computer if you look at the problem creatively enough.

So it turns out that the sum of the first n natural numbers (for any n) is:

Let’s apply that to our first 100 numbers and see if we really needed to write a computer program to sum 1 to 1000. Plugging 100 in for n we get (100(100 + 1))/2 or 5050.

So is there an easy way to get the sum of squares? It turns out that there is indeed:

Okay so the sum of the squares of 1 to 100 is 338,350 and the square of the sums is 25,502,500. The difference, therefore, is 25,164,150. At this point one could realistically ask, “So what?” (and who could blame you?)

It turns out that the sum of squares is an important technique in statistics for determining sample variance. That is to say, the amount that a set of data numbers varies from the average value. The bigger the variance, the more likely you’re going to have go back to the old drawing board and re-think your experiment. The traditional way to calculate variance is:

  • Find the average (mean) of the sample numbers.

  • Subtract each value from the mean and square the difference.

  • Add up all of the squared differences.

So if all of your data were perfect then the differences from the mean would be zero, which sums up to a total variance of zero. Such is the way of a perfect world. But the more your actual data points vary (see what I did there?), the bigger the difference from the mean and the bigger your variance.

That’s all well and good but where am I going with this? It turns out that there’s a shortcut way to get sample variance:

  • Sum up your sample data values and square the sum

  • Sum the squares of your sample data

  • Subtract the square of the sum from the sum of the squares

  • Divide by the number of data values

You don’t have to calculate the mean or the squares of the differences from the mean AND we’re back to our original technique of subtracting the square of sums from the sum of the squares. As your sample size gets bigger, this saves us a TON of work.

Thus endeth the lesson….