Duncan's blog

October 17, 2008

Project Euler

Filed under: Coldfusion,Project Euler — duncan @ 11:35 pm
Tags: , , , ,

Project Euler is:

"… a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems."

I found the site from a story on the Daily WTF, showing a less than optimal way someone had solved one of the Euler problems for a job interview test.

I thought it might be interesting to see how many of these I could do in CFML. Both to increase my basic mathematics knowledge, and improve my Coldfusion.

Once you register with the site, you can submit your answer for any problem and it’ll log if you get it correct. It’ll also give you access to a forum where people discuss the problem, and have a PDF outlining ways you could have tackled it.

So far I’ve just managed the first two and still working on the third.

1. Find the sum of all the multiples of 3 or 5 below 1000.
Simply a case of looping and using the MOD function.

2. Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
Again, looping and using MOD. The only tricky part is getting your head round how many variables you’ll need to use to store values as you progress through the Fibonacci series.

It seems that, from reading the PDFs after completing, and from how I’m getting on so far with the third puzzle, there is more than one way to solve these, and the brute force method of looping through all values isn’t going to be the most efficient. Many of the problems seem to deal with very large numbers, which could pose interesting challenges for Coldfusion. When you register, they have a list of programming languages you can choose from; CFML wasn’t listed, although I’ve requested that they add it. The most popular ones seem to be C/C++, Python, Java, C# and Haskell, although everything from Ada to Prolog is represented.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: