division by 7 efficiently ???

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Wed Feb 7 06:03:58 EST 2007


Roel Schroeven schreef:
> garrickp at gmail.com schreef:
>> I had considered this, but to halve, you need to divide by 2. Using
>> random, while potentially increasing the number of iterations, removes
>> the dependency of language tricks and division.
> 
> It's possible to use Fibonacci numbers instead of halving each time; 
> that requires only addition and subtraction. Unfortunately I forgot 
> exactly how that works, and I don't have the time to look it up or to 
> try to reproduce it now. Maybe later.
> 
> AFAIK that method is not commonly used since binary computers are very 
> good at dividing numbers by two, but it would be a good method on 
> ternary or decimal computers.

Responding to myself since I found an explanation in the obvious place:

http://en.wikipedia.org/wiki/Fibonacci_search_technique

It is meant for search in ordered arrays though; I don't think it can be 
adapted for searching in mathematic intervals.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven



More information about the Python-list mailing list