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/040475.html below:

[Python-Dev] Tail recursion

[Python-Dev] Tail recursion [Python-Dev] Tail recursionAahz aahz at pythoncraft.com
Thu Nov 27 12:50:39 EST 2003
On Thu, Nov 27, 2003, Andrew Koenig wrote:
>Tim Peters:
>>
>> A different approach makes iteration much more natural:  the number of
>> digits in n (>= 0) is the least i >= 1 such that 10**i > n.  Then
>> iterative
>> code is an obvious search loop:
>> 
>>     i = 1
>>     while 10**i <= n:
>>         i += 1
>>     return i
> 
> This code relies on 10**i being exact.  Is that guaranteed?

For Python ints, yes.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Weinberg's Second Law: If builders built buildings the way programmers wrote 
programs, then the first woodpecker that came along would destroy civilization.

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