Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'else:': 0.03; 'def': 0.12; 'btw': 0.16; 'hint': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'import': 0.22; 'math': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'sep': 0.31; 'fri,': 0.33; 'received:google.com': 0.35; 'false': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'tell': 0.60; 'number:': 0.66; '11:44': 0.84 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=WBZYRf3lIg2uHdlgrFbrRyvDK4AgBRv3hzxriZQQw4M=; b=QGYKeFErdZg356GHB0x4eqPjEpuDWO2a8PvqKAd46J9g0LP+Gud7OZ7Vo9MidXwiRI mTVEizoCEa95A0Wpu/TINBzIt+3ATxmTQVsD/rrAhiaTeX3zO/yBesMv3/1VmDgiTiVJ e3WSStsNfXcw6Fj7p6YU3lhtC06+47Mgrr+uPQqNiXq4AQ0yBQDCJfXnPK6E8lP3wERb JfslIwGSs2i/mqoGkLVVkW3kxPgHa4ITkiABKhVt8fDN88UphRgmpjor/JqxL8MRDi8p 5wiQdsPmiBSHXs7+fOjLiD3BV8OlWrhBK1IB9VNx3xONSAwP8f/KDCjdmkvQ1HaKKS/w lNyw== X-Received: by 10.70.140.102 with SMTP id rf6mr25783939pdb.4.1409951083254; Fri, 05 Sep 2014 14:04:43 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1enj0att6bkrnvb81rhma5dbuk3h28agl8@4ax.com> From: Ian Kelly Date: Fri, 5 Sep 2014 15:04:03 -0600 Subject: Re: My backwards logic To: Python Content-Type: text/plain; charset=UTF-8 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409951086 news.xs4all.nl 2933 [2001:888:2000:d::a6]:46726 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77618 On Fri, Sep 5, 2014 at 11:44 AM, Seymore4Head wrote: > BTW since I am getting no grade, I much prefer the answer than a hint. > The best hint IMO is to tell me how you would do it. from math import ceil, sqrt def is_prime(n): if n < 2: return False if n % 2 == 0: return n == 2 return all(n % x != 0 for x in range(3, int(sqrt(n)) + 1, 2)) while True: n = int(input("Enter a number: ")) if is_prime(n): print("{} is prime.".format(n)) else: print("{} is not prime.".format(n))