Sunday 2 October 2016

Project Euler- get students coding to solve maths problems

Could your students code a simple program to solve this maths problem?

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

ProjectEuler.net is a website that proposes maths problems of varying difficulty which can be solved by developing simple computer programs. For example, here’s some Javascript code I wrote in https://repl.it to solve the first problem:

var n;
var total = 0;

for (n=1; n <= 999; n++ )
{
if(n%3===0)
{
total = total + n;
}
if(n%5===0)
{
total = total + n;
}
if(n%3 ===0 && n%5 ===0)
{
total = total – n;
}
}

The 550+ problems start relatively straight-forward, such as above and increase in difficulty as you move through them. You submit your solution to each question and it tells you that you are the nth person to solve it etc.

As coding is part of the National Curriculum these days, students should have the skills to access the problems in Project Euler.

A fun cross-curricular link? An extra-curricular maths club?

first seen http://www.greatmathsteachingideas.com

No comments:

Post a Comment