<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentários em: Prime factors code in C and Python</title>
	<atom:link href="http://www.blog.amrlima.info/archives/865/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.amrlima.info/archives/865</link>
	<description>gnu/linux, cultura livre e outras divagações</description>
	<lastBuildDate>Sat, 04 Feb 2012 23:02:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Por: wayne</title>
		<link>http://www.blog.amrlima.info/archives/865/comment-page-1#comment-507</link>
		<dc:creator>wayne</dc:creator>
		<pubDate>Sat, 20 Feb 2010 19:09:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.amrlima.info/?p=865#comment-507</guid>
		<description>VMAX = 25
 
#Prime numbers &lt; 100
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
factors = [0]*VMAX #Prime factors
repeat = [0]*VMAX #Store times each factor repeats
i = 0
n = 0
k = 0
spacer = 0 
a = raw_input(&quot;Type a number to find it&#039;s prime factors:&quot;)
 
#Start to divide the number by prime numbers while a is not 1
for i in range(VMAX): 
 
    while ((a != 1) &amp; (int (a) % primes[i] == 0)):
 
        a = int (a) / primes[i]
 
        factors[i] = primes[i] # The prime factor is the one being used
 
        n = n + 1 #*Count how many times each prime is used

        # formatting
        if(spacer == 0):
            print 
            spacer = spacer + 1
        else:
	  if(n == 1):
              print
	      print
	print primes[i], 
        print n,
        print &quot; &quot;,

    if (int (a) % primes[i] == 0):
        n = 0 #Reinitialize counter
    repeat[k] = n

    n = 0
    k = k + 1
print 
print
print &quot;Prime factors:&quot;
 
#Print all factors in the array != 0
for i in range(VMAX):
 
    if (factors[i] !=0):
    #Since x ^ 0 = 1, we have to print x ^ 1 instead
        if (repeat[i] == 0):
            print factors[i],
        else: print &quot;%s ^ %s &quot; % (factors[i], repeat[i]),</description>
		<content:encoded><![CDATA[<p>VMAX = 25</p>
<p>#Prime numbers &lt; 100<br />
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]<br />
factors = [0]*VMAX #Prime factors<br />
repeat = [0]*VMAX #Store times each factor repeats<br />
i = 0<br />
n = 0<br />
k = 0<br />
spacer = 0<br />
a = raw_input(&quot;Type a number to find it&#039;s prime factors:&quot;)</p>
<p>#Start to divide the number by prime numbers while a is not 1<br />
for i in range(VMAX): </p>
<p>    while ((a != 1) &amp; (int (a) % primes[i] == 0)):</p>
<p>        a = int (a) / primes[i]</p>
<p>        factors[i] = primes[i] # The prime factor is the one being used</p>
<p>        n = n + 1 #*Count how many times each prime is used</p>
<p>        # formatting<br />
        if(spacer == 0):<br />
            print<br />
            spacer = spacer + 1<br />
        else:<br />
	  if(n == 1):<br />
              print<br />
	      print<br />
	print primes[i],<br />
        print n,<br />
        print &quot; &quot;,</p>
<p>    if (int (a) % primes[i] == 0):<br />
        n = 0 #Reinitialize counter<br />
    repeat[k] = n</p>
<p>    n = 0<br />
    k = k + 1<br />
print<br />
print<br />
print &quot;Prime factors:&quot;</p>
<p>#Print all factors in the array != 0<br />
for i in range(VMAX):</p>
<p>    if (factors[i] !=0):<br />
    #Since x ^ 0 = 1, we have to print x ^ 1 instead<br />
        if (repeat[i] == 0):<br />
            print factors[i],<br />
        else: print &quot;%s ^ %s &quot; % (factors[i], repeat[i]),</p>
]]></content:encoded>
	</item>
</channel>
</rss>

