I'm a professional game developer from Wakefield, England, working as a senior programmer for Rebellion North.
I'm a married father of five and I a also sometimes do Retroburn stuff.
Martin 'Bytrix' Caine
Father. C++ Games Programmer. Cyclist. Guitarist.
2013 3d alphalabs amazon apple archivirtual asynchronous battlefield bad company 2 ben 10 bepu beta blackmagic design blog blue marble bootcamp borderlands bsp calibration charity charvel childsplay comments competition content tracker counter-strike crash csgo css3 cycling dear esther deferred deus ex develop conference direct x discipline documentation doom 3 bfg dpi dr bott eidos elite force email deliverability eurogamer expo facebook focus fresnel game development game horizon game republic gamedev games gaming geoip girls make games global offensive grid guitar half-life 2 hawken hd7 hobbyist htc humble indie bundle imac indie indie trials indietrials intensity pro ip-countryside iron man 3 jamulus rift jquery kids kinect launch conference left 4 dead live lost mac mac osx manchester manhacks mass effect 2 matrox maya minecraft mirrors edge montreal morrowind movies museum of the microstar music mxo2 mini mysql nausea network networking nokia normal mapping obj oculus rift omnitrix ouya pedal for pounds php physics playstation suite port25 portal portal 2 positron posters powermta project aedra project euler promotion properties proton pulse ps vita ps4 psn racer reddit rendering retroburn game studios reviews rift racer riftracer roadkill roller coaster sdl2 shadow racers sharks shoct skyrifters snds space cadet spam trap star trek steam stencyl storage super stock sd1 fr superhot team fortress 2 tesselating tesselation texture editor thunderbird thunderclap ticktock games tiga track builder track bulder trials tv twitter uk ultimatrix usergroup vequencer video vireio visual assist visual studio vorpx voucher vr vr cinema war thunder warren web willow windows 8 windows 8.1 windows phone 7 workbench wp7 wp7dev xbla xblig xblig network xbox xbox live indie games xna xnaukug xperia play zombies on the holodeck
Email Deliverability
Monday, May 31st 2010 / Web

Project Euler - Problem 1

Someone I'm following on Twitter posted a link to an interesting site called Project Euler. It's full of interesting maths puzzles which are designed in such a way that you should create a program to calculate the result for you.

I like the look of the puzzles on the site and they remind me a little of the ones I've done in the past on the Facebook Puzzles page.

I've decided to start working my way through them when I get spare time and I'll be trying to work out PHP solutions to the problems and will post them here.

The details for problem 1 are below:

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.

The program was pretty simple, just work up from 1 to 999 and if the number is divisible by 3 or 5 add it to the total and output:

*  ProjectEuler.net  *  Problem 1  *  2010-05-31  *  Martin Caine *

$total 0;

// check $i between 1 and 999
for( $i=1$i<1000$i++ )
// if $i divides by 3 or 5 add to the total
if( ($i/3)==(int)($i/3) || ($i/5)==(int)($i/5) )
$total += $i;



If you found this post helpful please leave a comment below:
Tags:   php   project euler   web