A few years ago I did several of the Project Euler puzzles, a series of mathematical problems that are good programming exercises. I started out doing them in ColdFusion, but ended up doing a a few in Python due to its better abilities at dealing with massive numbers and calculations.
I’ve now decided to convert at least some of them from CFML / Python code into PHP, as a little tutorial for myself to increase my familiarity with some of its basic syntax. I’m doing this for basically the same reasons my colleague Adam Cameron is shifting his blog’s focus from ColdFusion to PHP.
I’m not going to try and solve the problems that I’ve already done by looking at them completely from scratch. Instead I’ll assume my logic or approach from before was basically sound, and try to simply convert the code into PHP, perhaps with minor improvements.
What I’m hoping is I’ll get used to common PHP functions and perhaps some gotchas that a newcomer to the language wouldn’t automatically be aware of. If you happen to be reading any of these, have some experience in the language and spot anything daft I’m doing or know better approaches and so on, I’d appreciate any feedback.
So without further ado, here’s the first Project Euler puzzle, a load more will hopefully follow.