A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/040467.html below:

[Python-Dev] Tail recursion

[Python-Dev] Tail recursion [Python-Dev] Tail recursionDevin devin at whitebread.org
Thu Nov 27 14:19:04 EST 2003
On Thu, 27 Nov 2003, Andrew Koenig wrote:

> --snip--
> Moreover, I don't know how to write an interative version that is as
> easy to understand as the recursive version.

::Lurk mode off::

import math

def numdigits(n):
    assert (n >= 0) and ((n % 1) == 0)
    if n < 10:
        return 1
    return int(math.log10(n)) + 1

(not iterative, but it'll do :)

::Lurk mode on::

-- 
Devin
devin at whitebread.org
http://www.whitebread.org/


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4