<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:evnet="http://www.mscommunities.com/rssmodule/"><channel><title>Comment Feed for Puzzle series: Addition of Four Primes (Posts on Channel 8)</title><atom:link rel="self" type="application/rss+xml" href="http://channel8.msdn.com/posts/puzzle-series-summation-of-four-primes/rss/default.aspx" /><image><url>http://mschnlnine.vo.llnwd.net/d1//App_Themes/Channel8/images/feedimage.png</url><title>Comment Feed for Puzzle series: Addition of Four Primes (Posts on Channel 8)</title><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/</link></image><description>Puzzle series: Addition of Four Primes</description><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/</link><language>en-us</language><pubDate>Mon, 14 Jan 2008 01:56:04 GMT</pubDate><lastBuildDate>Mon, 14 Jan 2008 01:56:04 GMT</lastBuildDate><generator>EvNet (EvNet, Version=1.0.3121.26304, Culture=neutral, PublicKeyToken=null)</generator><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;I did not go through all the posts here. But having&amp;nbsp; read the first few, in continuation to what Trix posted, I think we can check this:&lt;/p&gt;
&lt;p&gt;If it is an even number: What Trix says works good(Goldbachs Conjecture)&lt;/p&gt;
&lt;p&gt;If it is odd number: subtract 5 from the number. We will be left with 5, even number. 5=2+3, for even number again we can go by the Goldbachs Conjecture.&lt;/p&gt;
&lt;p&gt;The smallest number I could think of to express as a combination of 4 primes is 8(2, 2, 2, 2). Lets take the next: 9. &lt;/p&gt;
&lt;p&gt;9=5+4&lt;/p&gt;
&lt;p&gt;which means 2,3,2,2&lt;/p&gt;
&lt;p&gt;so I think this works for all the numbers.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But... I haven't yet checked the efficiency (time and space complexity) of this... will do it next week when I am free again..&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1342</link><pubDate>Mon, 14 Jan 2008 01:56:04 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1342</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1342/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I did not go through all the posts here. But having&amp;nbsp; read the first few, in continuation to what Trix posted, I think we can check this:
If it is an even number: What Trix says works good(Goldbachs Conjecture)
If it is odd number: subtract 5 from the number. We will be left with 5, even&amp;#8230;</evnet:previewtext><dc:creator>Ambica</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1342/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>Actually I think that my solution is O(n) in the worst case where n is the input number. (without including prime number generation).&lt;br /&gt;OTOH, AlanSpillane solution is O(n^4) as you said again without prime number generation.&lt;br /&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1207</link><pubDate>Wed, 09 Jan 2008 03:39:18 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1207</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1207/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Actually I think that my solution is O(n) in the worst case where n is the input number. (without including prime number generation).OTOH, AlanSpillane solution is O(n^4) as you said again without prime number generation.</evnet:previewtext><dc:creator>jaircazarin</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1207/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;Jaircazarin your solution even though it's not brute force it basically working on the same level. the difference is that you initially fill your vector with all possible prime numbers from 0 to 10000000.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;even though your program funs flawlessly you wil suffer a huge tax on the for loop to get all prime numbers. now you can solve that by appsing it to a file where you can read the data if it's not found and this will effective reduce your runtime effiency by more than half.in terms of speed both of you&amp;nbsp; guys &lt;a id="ctl00_MainPlaceHolder_EntryList_ctl02_EntryTemplate_UsernameLink" href="http://channel8.msdn.com/People/jaircazarin/"&gt;jaircazarin&lt;/a&gt;&amp;nbsp;and &lt;a id="ctl00_MainPlaceHolder_EntryList_ctl07_EntryTemplate_UsernameLink" href="http://channel8.msdn.com/People/AlanSpillane/"&gt;AlanSpillane&lt;/a&gt;&amp;nbsp;| all have almost the same run time speed you guys are rough about big-oh of log n. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Me personally i prefare Jaircazarin version since it has the possibilty to be very effiecient&amp;nbsp;if data is stored remotely or better yet if the algorithm is called more than once in&amp;nbsp; a program.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I wil try and edit your code and see if i can come up with anything better, but you guys have done a great job on the algorithm&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;*ok change that &lt;a id="ctl00_MainPlaceHolder_EntryList_ctl02_EntryTemplate_UsernameLink" href="http://channel8.msdn.com/People/jaircazarin/"&gt;jaircazarin&lt;/a&gt;&amp;nbsp;you are around big-oh logn and AlanSpillane has about bif-oh n^4&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1202</link><pubDate>Wed, 09 Jan 2008 02:23:46 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1202</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1202/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Jaircazarin your solution even though it's not brute force it basically working on the same level. the difference is that you initially fill your vector with all possible prime numbers from 0 to 10000000.&amp;nbsp;
even though your program funs flawlessly you wil suffer a huge tax on the for loop to&amp;#8230;</evnet:previewtext><dc:creator>platinumacetric</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1202/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;Your solution is the so called brute force approach, check out my solution &lt;/p&gt;
&lt;p&gt;&lt;a href="http://jaircazarincode.googlecode.com/svn/trunk/Channel8/Puzzle_Series/FourPrimes.cpp"&gt;http://jaircazarincode.googlecode.com/svn/trunk/Channel8/Puzzle_Series/FourPrimes.cpp&lt;/a&gt;&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1052</link><pubDate>Sun, 06 Jan 2008 03:18:27 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1052</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1052/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Your solution is the so called brute force approach, check out my solution 
http://jaircazarincode.googlecode.com/svn/trunk/Channel8/Puzzle_Series/FourPrimes.cpp</evnet:previewtext><dc:creator>jaircazarin</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1052/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;I don't have enough time to explain my algorithm (maybe tomorrow), but here is my implementation.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jaircazarincode.googlecode.com/svn/trunk/Channel8/Puzzle_Series/FourPrimes.cpp"&gt;http://jaircazarincode.googlecode.com/svn/trunk/Channel8/Puzzle_Series/FourPrimes.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Drop me an email&amp;lt;jair.cazarin[at]gmail.com&amp;gt; if somebody have a question.&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1051</link><pubDate>Sun, 06 Jan 2008 03:16:34 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1051</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1051/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I don't have enough time to explain my algorithm (maybe tomorrow), but here is my implementation.
http://jaircazarincode.googlecode.com/svn/trunk/Channel8/Puzzle_Series/FourPrimes.cpp
Drop me an email&amp;lt;jair.cazarin[at]gmail.com&amp;gt; if somebody have a question.</evnet:previewtext><dc:creator>jaircazarin</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1051/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>Here's a thought to chew on:&lt;br /&gt;&lt;br /&gt;Given some number K to split into four primes A, B, C and D, these are all going to be near to K/4.&lt;br /&gt;&lt;br /&gt;Why not then pair up two numbers (say A and B, C and D) and increase one and decrease the other until both are prime. Since both numbers are significantly smaller than K, you don't need to compute as many primes to start off with, and primes are going to be closer together at K/4 than at K.&lt;br /&gt;&lt;br /&gt;And for those of you wanting to make a series of primes, consider using an algorithm like:&lt;br /&gt;&lt;br /&gt;public static List&amp;lt;int&amp;gt; PrimeSeries(int K)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;int&amp;gt; primeseries = new List&amp;lt;int&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primeseries.Add(2);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool isPrime;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 3; i &amp;lt; K; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isPrime = true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (int prime in primeseries)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i % prime == 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {// i is divisible by the prime, i.e. is a constant multiple of it, ie. is not prime&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isPrime = false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isPrime)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primeseries.Add(i);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return primeseries;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;It should be a bit faster, and less memory intensive than the sieve methods for reasonably sized numbers (ones that fit into an int for instance)&lt;br /&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1050</link><pubDate>Sun, 06 Jan 2008 02:54:16 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1050</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1050/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Here's a thought to chew on:Given some number K to split into four primes A, B, C and D, these are all going to be near to K/4.Why not then pair up two numbers (say A and B, C and D) and increase one and decrease the other until both are prime. Since both numbers are significantly smaller than K,&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1050/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>@ Trix:&lt;br /&gt;&lt;br /&gt;For odd that seems tricky, because "Waring's&amp;nbsp; prime number conjecture,
it states that every odd integer is either prime or the sum of three
primes." Well, if it is only a sum of 3 primes how can you get 4 out of
it?&lt;br /&gt;&lt;br /&gt;You can turn one of the primes into two primes.&lt;br /&gt;&lt;br /&gt;Eg. 13 = 11 + 2&lt;br /&gt;&lt;br /&gt;So for the number&lt;br /&gt;&lt;br /&gt;23 = 13 + 7 + 3&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = (11 + 2) + 7 + 3&lt;br /&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1048</link><pubDate>Sun, 06 Jan 2008 02:41:20 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1048</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1048/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>@ Trix:For odd that seems tricky, because "Waring's&amp;nbsp; prime number conjecture,
it states that every odd integer is either prime or the sum of three
primes." Well, if it is only a sum of 3 primes how can you get 4 out of
it?You can turn one of the primes into two primes.Eg. 13 = 11 + 2So for the&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1048/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;
				
						
								Ok, before I start I must mention that I have little experience developing complex algorithms but I really enjoy trying to solve them. I have read the above posts and can follow it easily but I wanted to code it first the way I pictured it in my head, and then learn from the approach you guys take. This is definitely the most inefficient solution possible but it’s a starting point for me 
						
						
								J
						
						
								
								&lt;o:p&gt;
								&lt;/o:p&gt;
						
				
		&lt;/p&gt;
&lt;p&gt;Recently I read an excellent book called “the music of the primes” by Marcus du Sautory and within it he explains &lt;i&gt;the sieve of Eratosthenes&lt;/i&gt;. &amp;nbsp;&amp;nbsp;(&lt;a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes"&gt;Here on Wikipedia&lt;/a&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;He began by writing out all the numbers from 1 to 1000. He then took the first prime, 2, and struck off every second number on the list. Since all these numbers were divisible by 2, they weren’t prime. He then moved to the next number that hadn’t been struck off, namely 3. He then struck off every third number after 3. Since these were all divisible by 3, they weren’t prime either. He kept doing this, just picking up the next number which hadn’t been struck from the list and striking off all the numbers divisible by the new prime. By this semantic process he produced tables of primes!!&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;I then found this article on &lt;a href="http://www.codeproject.com/KB/recipes/highspeed_primenumbers.aspx"&gt;codeproject&lt;/a&gt; which shows how to implements it in c#.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;Essentially what I did was get all the primes between the 2 and the number entered and store them. I then loop through these adding them up until I get a match. It works for small numbers but VERY POOR for large numbers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;int value = int.Parse(NumbetextBox.Text);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;int[] primes = new int[value];&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;BitArray numbers = new BitArray(value, true);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;for (int i = 2; i &amp;lt; value; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;if (numbers[i]){&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;for (int j = i * 2; j &amp;lt; value; j += i)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; numbers[j] = false;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;int numPrimes = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;for (int i = 2; i &amp;lt; value; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;if (numbers[i])&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; primes[numPrimes] = i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; numPrimes++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;for (int k = 0; k &amp;lt; numPrimes; k++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; for (int l = 0; l &amp;lt; numPrimes; l++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int m = 0; m &amp;lt; numPrimes; m++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for (int n = 0; n &amp;lt; numPrimes; n++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int num = primes[k] + primes[l] + primes[m] + primes[n];&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (num == value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;Output values to screen&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;}&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;I realise that this solution is of little use to anyone but I am happy with my first attempt. &lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;Looking forward to what you guys can do.&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1047</link><pubDate>Sun, 06 Jan 2008 01:30:36 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1047</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1047/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>	
						
								Ok, before I start I must mention that I have little experience developing complex algorithms but I really enjoy trying to solve them. I have read the above posts and can follow it easily but I wanted to code it first the way I pictured it in my head, and then learn from the&amp;#8230;</evnet:previewtext><dc:creator>AlanSpillane</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1047/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;Hm I see, I wonder if it would be reasonable if excel could do this, i'm guessing not.&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1022</link><pubDate>Sat, 05 Jan 2008 20:29:43 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1022</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1022/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Hm I see, I wonder if it would be reasonable if excel could do this, i'm guessing not.</evnet:previewtext><dc:creator>Trix</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1022/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;This is a nice puzzle. Trix really has already a good stand with his idea. Trix you could also - instead of writing it in code - use pseudo code, which means you only write down a list of operations that do it... like for example going through a list of numbers and check how many values are uneven looks like this:&lt;/p&gt;
&lt;p&gt;numbersOfEven = 0&lt;br /&gt;loop until&amp;nbsp;end of list reached&lt;br /&gt;&amp;nbsp;&amp;nbsp; get number from list&lt;br /&gt;&amp;nbsp;&amp;nbsp; check if item value is even&lt;br /&gt;&amp;nbsp;&amp;nbsp; when even&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; numbersOfEven + 1&lt;br /&gt;end loop&lt;br /&gt;return numbersOfEven&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1021</link><pubDate>Sat, 05 Jan 2008 20:28:54 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1021</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1021/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>This is a nice puzzle. Trix really has already a good stand with his idea. Trix you could also - instead of writing it in code - use pseudo code, which means you only write down a list of operations that do it... like for example going through a list of numbers and check how many values are uneven&amp;#8230;</evnet:previewtext><dc:creator>littleguru</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1021/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;I see, I think your solution is quite good. You have provided more or less a certain number of ordered steps to get the solution.&lt;/p&gt;
&lt;p&gt;What is an algorithm? It is a "set of ordered instructions to solve a problem". We have several ways to represent algorithms. We can use natural languages, we can use pseudocode, or we can dive into and use more specific languages like C# or Visual Basic.&lt;/p&gt;
&lt;p&gt;At the end, we will find that all of them are "partial" translations of natural (high-level) languages into something that is getting increasingly similar to "machine code", the final result needed in order to compute the problem with a PC.&lt;/p&gt;
&lt;p&gt;So, you programmers, now we have one more clue, the verbal reasoning of Trix about a solution to the problem... What about code? Or also, what about a different approach to the problem?&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1018</link><pubDate>Sat, 05 Jan 2008 19:58:42 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1018</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1018/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I see, I think your solution is quite good. You have provided more or less a certain number of ordered steps to get the solution.
What is an algorithm? It is a "set of ordered instructions to solve a problem". We have several ways to represent algorithms. We can use natural languages, we can use&amp;#8230;</evnet:previewtext><dc:creator>Miguel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1018/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>I'm studying to be a chemical engineer, coding is something I'd like to learn but it is like another language, but I'm always just so busy during school. I don't really know much about code, at least I don't think so, but I think with logic I can figure things out, and how I would code something.</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1016</link><pubDate>Sat, 05 Jan 2008 19:52:06 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1016</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1016/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I'm studying to be a chemical engineer, coding is something I'd like to learn but it is like another language, but I'm always just so busy during school. I don't really know much about code, at least I don't think so, but I think with logic I can figure things out, and how I would code something.</evnet:previewtext><dc:creator>Trix</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1016/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;It may be tricky, but I would like all of you to try formalizing and CODING the algorithm. And then, search for the most efficient solution. Most of times, we can think about a problem and consider it is more difficult that the actual level of difficulty.&lt;/p&gt;
&lt;p&gt;Intuitive reasoning or demonstration&amp;nbsp;of the problem is more or less easy but we should practice how to translate reasonings and colloquial language into code. This way we are "standardizing" our explanations, then other people could understand, and also we can realize about some tricky aspects...&lt;/p&gt;
&lt;p&gt;:-)&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1015</link><pubDate>Sat, 05 Jan 2008 19:48:47 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1015</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1015/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>It may be tricky, but I would like all of you to try formalizing and CODING the algorithm. And then, search for the most efficient solution. Most of times, we can think about a problem and consider it is more difficult that the actual level of difficulty.
Intuitive reasoning or&amp;#8230;</evnet:previewtext><dc:creator>Miguel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1015/Trackback.aspx</trackback:ping></item><item><title>Re: Puzzle series: Addition of Four Primes</title><description>&lt;p&gt;This is tricky. I can do evens fine.&lt;/p&gt;
&lt;p&gt;First I'd have a&lt;a href="http://en.wikipedia.org/wiki/List_of_prime_numbers"&gt;&lt;u&gt; list of prime numbers f&lt;/u&gt;&lt;/a&gt;rom (2-10000000).&lt;/p&gt;
&lt;p&gt;Ok, now I have to look at the input and figure out how to get 4 primes out of it.&lt;/p&gt;
&lt;p&gt;If the inputer = even integer I'd use this process:&lt;/p&gt;
&lt;p&gt;I'd divide by 2 and work in chunks. Using conjectures will help here.&lt;/p&gt;
&lt;p&gt;Example: Input 1000&lt;/p&gt;
&lt;p&gt;Divide by 2=500&lt;/p&gt;
&lt;p&gt;Hm well that is a rather large even number, but using Goldbachs Conjecture, I know there has to be two numbers that are prime that add up to 500. Using the list of Prime numbers, I would work backwards from 500 down. Selecting from a pool of x &amp;lt; 500 starting from the number closets to 500, I would select 499. I would then subtract this from 500, then see if the result was a prime number. 500-499=1, nope didn't work. If it were not I'd keep going down the list, next is 491. 500-491=9, nope. Next is 487. 500-487=13. Bingo! So from there, I know 487-13-487-13 works.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Example: Input 52&lt;/p&gt;
&lt;p&gt;Divide by 2 = 26 Two sets of 26, but 26 is even, not a prime.&lt;/p&gt;
&lt;p&gt;Here I would use Goldbach's Conjecture, and note that 26 has to be made up of two primes. From the list of prime numbers, I can figure out that 13+13 is infact 26.&lt;/p&gt;
&lt;p&gt;From here I now know that 13-13-13-13 works.&lt;/p&gt;
&lt;p&gt;Example: Input 14&lt;/p&gt;
&lt;p&gt;Divide by 2 = 7 So two sets of seven make up 14.&lt;/p&gt;
&lt;p&gt;Using Goldbach, I know that 7 has two prime numbers that make it up. Using my handy method of using a set list, I would choose the number closets to 7 from the left, which is 5, subtract that from 7, I get 2. 2 = prime 5 = prime. So 2-5-2-5 &lt;/p&gt;
&lt;p&gt;For odd that seems tricky, because "Waring's&amp;nbsp; prime number conjecture, it states that every odd integer is either prime or the sum of three primes." Well, if it is only a sum of 3 primes how can you get 4 out of it?&lt;/p&gt;
&lt;p&gt;My guess is since 2 is a special prime, you could subtract that at the beginning and still end up with an odd. 69-2 = 67. From there you can figure out the 3 that make up 67 and then add 2. I just don't know how to do that yet, I'll think and post back.&lt;/p&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1009</link><pubDate>Sat, 05 Jan 2008 19:24:04 GMT</pubDate><guid isPermaLink="true">http://channel8.msdn.com/Posts/Puzzle-series-Summation-of-Four-Primes/?CommentID=1009</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/1009/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>This is tricky. I can do evens fine.
First I'd have a list of prime numbers from (2-10000000).
Ok, now I have to look at the input and figure out how to get 4 primes out of it.
If the inputer = even integer I'd use this process:
I'd divide by 2 and work in chunks. Using conjectures will help&amp;#8230;</evnet:previewtext><dc:creator>Trix</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/1009/Trackback.aspx</trackback:ping></item></channel></rss>