Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'algorithm': 0.03; 'assign': 0.07; 'subject:two': 0.07; 'itself.': 0.11; 'division,': 0.16; 'subject:Problems': 0.16; 'subject:questions': 0.16; 'subject:these': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'integer': 0.17; 'meant': 0.21; 'simpler': 0.22; 'programming': 0.23; 'testing': 0.24; 'header:In-Reply-To:1': 0.25; 'necessary.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'factor': 0.29; 'no,': 0.29; 'received:209.85.215.46': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'needed': 0.35; 'nov': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'problems': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'more': 0.63; 'trial': 0.81; 'to:name:python': 0.84; 'dennis': 0.91; 'novice': 0.91; 'factors': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=9bA3lbUMmwMhWQxzKoI2Z0bjC5yG1WDM4j0zxfiSh0o=; b=WG5TO44Fz4QcwnayG4cPeK2oaT2rX7YDbpMDNtjoY3IPrZwrOERFENYtvKzYcISChF v/eL8d2lOFNLgaLfdW2U+H/n9g1TZpgz2HrseuN9S3e7PWyQ1b1gpRCOMLJOTRqwHlZa Jck02KpYOO1PpCGiYG71ulFmCMRUPtEwPjpq7uG6aSbOLkvx4N/dBLg7jahZsQlYFgsf fvv4OLe1SrJKBWylaDvM1aHAmNnNIdHPWIcGmveeUhbNZ/8NKQTvsUf/niDi6w2qLSD5 HqIU0ceoxFPu974WDiFit4KbHCeDmZdSLhMevMGDnWxufdHqIx9eo1eY4ld5DGDWGb78 PhWQ== MIME-Version: 1.0 In-Reply-To: References: <400c615f-4d93-4b8b-85ec-1bb4c47e30fe@googlegroups.com> From: Ian Kelly Date: Mon, 19 Nov 2012 23:32:37 -0700 Subject: Re: Problems on these two questions To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353393197 news.xs4all.nl 6893 [2001:888:2000:d::a6]:55843 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33588 On Mon, Nov 19, 2012 at 4:15 PM, Dennis Lee Bieber wrote: > On Sun, 18 Nov 2012 17:52:35 -0800 (PST), su29090 <129km09@gmail.com> > declaimed the following in gmane.comp.python.general: > >> >> I all of the other problems but I have issues with these: >> >> 1.Given a positive integer n , assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) >> > Google: Sieve of Eratosthenes (might be mis-spelled) No, the Sieve is nifty, but it's meant for generating sequences of primes, not for testing individual primality. It's also more complex than is necessary. A better starting place for a programming novice is with trial division, which is a somewhat simpler algorithm and all that is needed here.