<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: De volta à resolução de problemas</title>
	<atom:link href="http://tiagomadeira.net/de-volta-a-resolucao-de-problemas/feed" rel="self" type="application/rss+xml" />
	<link>http://tiagomadeira.net/de-volta-a-resolucao-de-problemas</link>
	<description>Idéias aleatórias de uma mente em desenvolvimento</description>
	<pubDate>Fri, 16 May 2008 03:14:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Tiago Madeira</title>
		<link>http://tiagomadeira.net/de-volta-a-resolucao-de-problemas#comment-126</link>
		<dc:creator>Tiago Madeira</dc:creator>
		<pubDate>Tue, 17 Jan 2006 17:20:01 +0000</pubDate>
		<guid isPermaLink="false">http://tiagomadeira.net/2005/09/16/de-volta-a-resolucao-de-problemas/#comment-126</guid>
		<description>It's implemented in ANSI C. :)</description>
		<content:encoded><![CDATA[<p>It&#8217;s implemented in ANSI C. <img src='http://tiagomadeira.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mathematician</title>
		<link>http://tiagomadeira.net/de-volta-a-resolucao-de-problemas#comment-125</link>
		<dc:creator>mathematician</dc:creator>
		<pubDate>Tue, 17 Jan 2006 17:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://tiagomadeira.net/2005/09/16/de-volta-a-resolucao-de-problemas/#comment-125</guid>
		<description>thanks for your interest.
sorry i forgot to tell you;
is it in C++ or in C?
i'm realy bad in this lesson i canT understand the difference between them.
i need C programming. 
again thanks for your help.
(my english is not good too no matter:))</description>
		<content:encoded><![CDATA[<p>thanks for your interest.<br />
sorry i forgot to tell you;<br />
is it in C++ or in C?<br />
i&#8217;m realy bad in this lesson i canT understand the difference between them.<br />
i need C programming.<br />
again thanks for your help.<br />
(my english is not good too no matter:))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tiago Madeira</title>
		<link>http://tiagomadeira.net/de-volta-a-resolucao-de-problemas#comment-124</link>
		<dc:creator>Tiago Madeira</dc:creator>
		<pubDate>Tue, 17 Jan 2006 16:01:39 +0000</pubDate>
		<guid isPermaLink="false">http://tiagomadeira.net/2005/09/16/de-volta-a-resolucao-de-problemas/#comment-124</guid>
		<description>Hey...

I used a simple recursive function. The solution, implemented in C, is here: &lt;a href="http://tiagomadeira.net/script/sprime.c" rel="nofollow"&gt;sprime.c&lt;/a&gt;

The logic is the following:
1. The function receives "n".
2. If n is greater than 1, we do function(n-1)
3. If n=1, we just return the four only primes with one digit: 2, 3, 5 and 7.
4. We have an array called &lt;strong&gt;cont&lt;/strong&gt;, that keep the value of numbers with each number of digits (its index).
5. After do function(n-1), when n is greater than 1, I do the following loop:

for i=0 until cont[n-1]; do
	for j=1 until 9, increasing 2; do
		num=prime[n-1][i]*10+j;
		if (is_prime(num)) {
			prime[n][cont[n]++]=num;
		}
	}
}

This function, only make num=prime[n-1][i]*10+j, where prime[n-1][i] is a prime with less one algarism and we do it times 10 because we are on decimal system. We do plus "j" because "j" is a odd value that can be the unit of a prime.

So, we formed all the primes with each n. :)

Understood? Sorry my bad english, i'm trying to improve it... lol

Any problem, answer me!</description>
		<content:encoded><![CDATA[<p>Hey&#8230;</p>
<p>I used a simple recursive function. The solution, implemented in C, is here: <a href="http://tiagomadeira.net/script/sprime.c" rel="nofollow">sprime.c</a></p>
<p>The logic is the following:<br />
1. The function receives &#8220;n&#8221;.<br />
2. If n is greater than 1, we do function(n-1)<br />
3. If n=1, we just return the four only primes with one digit: 2, 3, 5 and 7.<br />
4. We have an array called <strong>cont</strong>, that keep the value of numbers with each number of digits (its index).<br />
5. After do function(n-1), when n is greater than 1, I do the following loop:</p>
<p>for i=0 until cont[n-1]; do<br />
	for j=1 until 9, increasing 2; do<br />
		num=prime[n-1][i]*10+j;<br />
		if (is_prime(num)) {<br />
			prime[n][cont[n]++]=num;<br />
		}<br />
	}<br />
}</p>
<p>This function, only make num=prime[n-1][i]*10+j, where prime[n-1][i] is a prime with less one algarism and we do it times 10 because we are on decimal system. We do plus &#8220;j&#8221; because &#8220;j&#8221; is a odd value that can be the unit of a prime.</p>
<p>So, we formed all the primes with each n. <img src='http://tiagomadeira.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Understood? Sorry my bad english, i&#8217;m trying to improve it&#8230; lol</p>
<p>Any problem, answer me!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mathematician</title>
		<link>http://tiagomadeira.net/de-volta-a-resolucao-de-problemas#comment-123</link>
		<dc:creator>mathematician</dc:creator>
		<pubDate>Tue, 17 Jan 2006 15:37:43 +0000</pubDate>
		<guid isPermaLink="false">http://tiagomadeira.net/2005/09/16/de-volta-a-resolucao-de-problemas/#comment-123</guid>
		<description>Hi!
Can you send me the solution of superprime_rib [N] solution untill thursday, in english please.
Thanks for your help</description>
		<content:encoded><![CDATA[<p>Hi!<br />
Can you send me the solution of superprime_rib [N] solution untill thursday, in english please.<br />
Thanks for your help</p>
]]></content:encoded>
	</item>
</channel>
</rss>
