<?xml version="1.0" encoding="ISO-8859-15"?>
<rss version="2.0"><channel>
<title>sieve of erastothenes in clean python</title>
<link>http://sange.fi/~atehwa/cgi-bin/piki.cgi/</link>
<description>Recent changes in sieve of erastothenes in clean python</description>
<item><title>sieve of erastothenes in clean python</title>
<link>http://sange.fi/~atehwa/cgi-bin/piki.cgi/sieve%20of%20erastothenes%20in%20clean%20python</link>
<guid>http://sange.fi/~atehwa/cgi-bin/piki.cgi/#1510917233</guid>
<description>&lt;p&gt;&lt;ins&gt;(nettipäiväkirja 17.11.2017) I tried to find a succinct 
implementation of Erastothenes' sieve using Python generators. I was 
astounded that it took more time to find a decent one than to write it. 
So, I'm contributing my version:&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;{{{ from itertools import count&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;def sieve(nums): p = next(nums) yield p yield from sieve(n for 
n in nums if n%p)&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;def primes(): return sieve(count(2)) }}}&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;The versions here 
(http://www.macdevcenter.com/pub/a/python/excerpt/pythonckbk_chap1/index
1.html?page=2) or here 
(https://stackoverflow.com/questions/2211990/how-to-implement-an-efficie
nt-infinite-generator-of-prime-numbers-in-python) are IMNSHO much less 
representative.&lt;/ins&gt; 

&lt;p&gt;&lt;ins&gt;* [merkintä: 2017-11] * [atehwa] * [kategoria: 
päiväkirjamerkintä]&lt;/ins&gt;

</description>
<pubDate>Fri, 17 Nov 2017 11:13:53 +0000</pubDate>
</item>

</channel></rss>
