Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'subject:code': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'precedence': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rules.': 0.16; 'so)': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; '2.x': 0.24; 'integer': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'division': 0.31; 'maybe': 0.34; 'subject:with': 0.35; 'should': 0.36; 'two': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; "you're": 0.61; 'email addr:gmail.com': 0.63; 'subject:this': 0.83; 'received:108': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Help me with this code Date: Tue, 05 Nov 2013 23:44:21 -0600 References: <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com> <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: pool-108-12-85-29.hstntx.dsl-w.verizon.net In-Reply-To: <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com> User-Agent: Groundhog Newsreader for Android 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383716672 news.xs4all.nl 15976 [2001:888:2000:d::a6]:35309 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58549 On Tue, 5 Nov 2013 17:51:00 -0800 (PST), chovdary@gmail.com wrote: > result += ((-1) ** (k+1))/2*k-1 One of two things are happening here. Maybe both. You're using Python 2.x (and should havesaid so) where integer division is truncated. You're missing around some part of the intended denominator. Check operator precedence rules. -- DaveA