<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Cycle detection - Page 20 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Cycle_detection&amp;p=19">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Cycle_detection&amp;p=21">3.Next</a>
</p>

<p>    # Find the position u of first repetition.        mu = 0    tortoise = x0    while tortoise != hare:        tortoise = f(tortoise)        hare = f(hare)   # Hare and tortoise move at same speed        mu += 1     # Find the length of the shortest cycle starting from x_u    # The hare moves one step at a time while tortoise is still.    # lam is incremented until ? is found.    lam = 1    hare = f(tortoise)    while tortoise != hare:        hare = f(hare)        lam += 1     return lam, mu</p>

<p>This code only accesses the sequence by storing</p><p>
<a accesskey="1" href="page.php?w=Cycle_detection&amp;p=19">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Cycle_detection&amp;p=21">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
