<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>math &#8211; CodePills.com</title>
	<atom:link href="https://codepills.com/tag/math/feed/" rel="self" type="application/rss+xml" />
	<link>https://codepills.com</link>
	<description>Helping you make a better code</description>
	<lastBuildDate>Sat, 16 Jan 2016 10:09:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Project Euler Problem 1 &#8211; Multiples of 3 and 5</title>
		<link>https://codepills.com/project-euler-problem-1-multiples-of-3-and-5/</link>
					<comments>https://codepills.com/project-euler-problem-1-multiples-of-3-and-5/#respond</comments>
		
		<dc:creator><![CDATA[Andrej Buday]]></dc:creator>
		<pubDate>Sat, 16 Jan 2016 10:09:38 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[math]]></category>
		<guid isPermaLink="false">http://codekopf.com/?p=377</guid>

					<description><![CDATA[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. <a href="https://codepills.com/project-euler-problem-1-multiples-of-3-and-5/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p>I was randomly searching for best place to learn &#8220;programming by doing&#8221; and I have found link on <a href="https://projecteuler.net/" rel="nofollow">Project Euler</a>. I really like the idea of the project and I decided to join. Here is a description of the first Project Euler problem:<span id="more-377"></span></p>
<blockquote><p>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.</p>
<p>Find the sum of all the multiples of 3 or 5 below 1000.</p></blockquote>
<p>The problem is very easy. We are checking division of the numbers 3 and/or 5, the end number is not high and an idea of the sum is very clear. Despite the fact we need to brute-forcefully iterate all over the first 1000 numbers, I did not think much about any other complicated algorithm. The brute-force can be enough in this case.</p>
<h2>PHP:</h2>
<pre class="lang:php decode:true ">&lt;?php 
$sum = 0;
for ($i=0;$i&lt;1000;$i++) {
	if(($i%3 == 0) OR ($i%5 == 0)){
		$sum += $i;
	}
}
echo $sum;
?&gt;
</pre>
<h2>JAVA:</h2>
<pre class="lang:java decode:true">public class Project_Euler_Problem_001 {

	public static void main(String[] args) {
		
		System.out.println("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.");
		System.out.println("Find the sum of all the multiples of 3 or 5 below 1000.");

		int sum = 0;
		for (int i = 0; i&lt;1000; i++) {
			if((i%3 == 0) || (i%5 == 0)){
				sum += i;
			}
		}
		System.out.println("\n"+ "Sum is: " + sum);;
	}
}</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://codepills.com/project-euler-problem-1-multiples-of-3-and-5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
