Find the greatest product of five consecutive digits in the 1000-digit number
April 19, 2008
Find the greatest product of five consecutive digits in the 1000-digit number.
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Solution 1
$num = "731671765313306249192251196744265747423553491949349698352031277450632 6239578318016984801869478851843858615607891129494954595017379583319528 5320880551112540698747158523863050715693290963295227443043557668966489 5044524452316173185640309871112172238311362229893423380308135336276614 2828064444866452387493035890729629049156044077239071381051585930796086 6701724271218839987979087922749219016997208880937766572733300105336788 1220235421809751254540594752243525849077116705560136048395864467063244 1572215539753697817977846174064955149290862569321978468622482839722413 7565705605749026140797296865241453510047482166370484403199890008895243 4506585412275886668811642717147992444292823086346567481391912316282458 6178664583591245665294765456828489128831426076900422421902267105562632 1111109370544217506941658960408071984038509624554443629812309878799272 4428490918884580156166097919133875499200524063689912560717606058861164 6710940507754100225698315520005593572972571636269561882670428252483600 823257530420752963450";
$l = array();
for($i = 0; $i < 995; $i++)
{
$part = substr($num, $i, 5);
$part = preg_split(‘//’, $part, -1, PREG_SPLIT_NO_EMPTY);
$l[] = array_product($part);
}
sort($l, SORT_NUMERIC);
reset($l);
echo end($l);
?>
Add all the natural numbers below one thousand that are multiples of 3 or 5
April 19, 2008
Quote from Project Euler website:
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.
Here are some of my PHP based solutions:
Solution 1a (minimised)
Solution 1b (beautified)
Solution 2 (minimised)(faster)
How to become a Freelance Writer using a blog
March 4, 2008
One of the best ways to become a freelance writer is to start a weblog, or blog for short, because it is very easy to get started and does not cost anything. You can set up your blog in ten minutes flat at http://blogger.com or one of the other providers free of charge.
Of course, just because it is easy to start blogging does not mean that it is easy to make money from your blog. Don’t expect to see any cash in your account straight away. Blogging for profit, certainly for the equivalent of a living wage, is an activity that will take time. It would be a good idea to get started as a side job or part time activity while you are working on other freelancing options or doing your day job. However, given time and regular attention, your blog – or blogs - will grow into a viable business.
As a professional blogger, it is important that you to pay close attention to how you present yourself in your blog. There are hundreds of thousands of blogs out there, with more being set up every day. It is more than likely that there are already several hundred well established blogs that are related to the theme of your blog and aimed at a similar niche market. It is therefore vital that the look and style of your blog appeals to your potential readership. If people find your blog difficult to relate to and have trouble reading it, they’ll swiftly move on never to be seen again.
Here are a few tips to make your blog more user-friendly and help you gain readers who will eagerly return to your blog again and again.
First, pay close attention to the format of your blog. Remember to KISS: “Keep It Sweet and Simple”! Visitors to your blog want to understand how to navigate their way through it right from the start. Most blogging platforms have similar formats, with links on the left or right margin, and posts listed with the most recent at the top. Make sure you use the links wisely. Only put links up that are truly related to the topic of your blog. The point is to give your readers additional information on your topic. Again, the KISS rule applies: “Keep It Short and Simple”!! There is no sense in overwhelming your readers with a mass of links to other sites; they will only click away from your blog more quickly and most likely not return again.
Secondly, think carefully before choosing the background and font color of your blog. Although there are a lot of colours to choose from, it’s best to stick with a light background and dark text. Studies have shown that the human brain can process dark text against a light background better than a light text against a dark background. A black background with a white text might look striking, but readers might not want to read it for long. One other thing, stick to a solid background colour instead of trying to use a pattern or design because the patterns inhibit easy reading and are, quite frankly, annoying to the reader.
Thirdly, don’t just write and post your blog entries without proofreading and editing them first. Remember, there is nothing that reduces your professional authority in the eyes of your readership more than bad spelling and grammar. If spelling and grammar are your weak points, write your articles on Microsoft Word or a similar word processing program and use the spell-checker before you post your article. The Internet is still largely text-based, so make a point of learning commonly misspelled words and grammatical errors. Also, use the “Preview”button to see how your article looks before you post it. Finally, check how it looks once it is uploaded and make any necessary edits until it is completely satisfactory.
Fourth, keep your blog fresh and interesting by posting at least once a day. With so much information available on the Internet, your readers may go elsewhere if you fail to keep them supplied with interesting daily content. If you don’t know what to write about, try posting a poll, a book or magazine review, a link to another blog, comment on a news story or post of list of helpful tips or useful sites related to your theme. Bear in mind that not every post has to be long and complicated; in fact, a stream of short and punchy posts is much better than less frequent but overly long articles. For the third time, remember to “KISS” your blog: “Keep It Short and Stimulating”! And commit to posting something everyday.
By following these guidelines you will keep your blog readable and interesting and that will be attractive to your visitors. The more visitors you get, the more your blog will grow in importance, and that in turn will enable you to get a profitable return from your blogging activities. Just make sure you present yourself in a professional way and keep your readers coming back for more new content each day. Within a short space of time you will have be running a profitable blog and will be ready to move on to create another, and another, and another.
By David Hurley
10 Recent Posts
How to become a Freelance Writer using a blog
One of the best ways to become a freelance writer is to start a weblog, or blog for short, because it is very easy to get started and does not cost anything. You can set up your blog in ten minutes flat at http://blogger.com or one of the other providers free of charge. Of course, just because it is easy to start blogging does not mean that it is easy to make money from your blog. Don’t expect to...
The pros and cons of a Flash website
Flash-based sites have been a craze since the past few years, and as Macromedia compiles more and more great features into Flash, we can only predict there will be more and more flash sites around the Internet. However, Flash based sites have been disputed to be bloated and unnecessary. Where exactly do we draw the line? Here’s a simple breakdown. The good: Interactivity Flash’s Actionscript...
How to choose a good domain
Choosing A Good Domain Name Choosing a domain name for your site is one of the most important steps towards creating the perfect internet presence. If you run an on-line business, picking a name that will be marketable and achieve success in search engine placement is paramount. Many factors must be considered when choosing a good domain name. This article summarizes all the different things to consider...
How to get maximum visibility using Pingbacks
So, your already using WordPress, but your struggling to get visibility, you feel like all the big communities are ignoring you. Well...
7 ways to get a successful Internet business
Have you ever thought about starting an internet business? It could really be as simple as opening a Yahoo Store, or on the other end...
Don’t get banned for Adsense Click Fraud
Many web site owners are getting their Google Adsense account terminated when they have done nothing wrong to deserve the punishment....
Call of Duty 4
War rages on in the fourth edition of Activision’s acclaimed war game. For the first time in the series, Call of Duty moves away...
Finally: Halo 3 Major symbol
Finally! Got my Halo 3 Major Symbol ‘Nuff said. Why not check out the rest of my Halo 3 Stats? Why not view...
A cruel tale
A seven-year old boy was at the center of a courtroom drama yesterday when he challenged a court ruling over who should have custody...
Xbox Boys
Oh come on, it is kinda good… :p Read More →


