Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To find the repeating pattern, just keep track of the values you use along the line:</p> <pre><code>1/5 = 1/101: 1 &lt; 101 =&gt; 0 (decimal separator here) 10 &lt; 101 =&gt; 0 100 &lt; 101 =&gt; 0 1000 &gt;= 101 =&gt; 1 1000 - 101 = 11 110 &gt;= 101 =&gt; 1 110 - 101 = 1 10 -&gt; match </code></pre> <p>As you reach the same value as you had at the second bit, the process will just repeat from that point producing the same bit pattern over and over. You have the pattern "0011" repeating from the second bit (first after decimal separator).</p> <p>If you want the pattern to start with a "1", you can just rotate it until it matches that condition:</p> <pre><code>"0011" from the second bit "0110" from the third bit "1100" from the fourth bit </code></pre> <p>Edit:<br> Example in C#:</p> <pre><code>void FindPattern(int n1, int n2) { int digit = -1; while (n1 &gt;= n2) { n2 &lt;&lt;= 1; digit++; } Dictionary&lt;int, int&gt; states = new Dictionary&lt;int, int&gt;(); bool found = false; while (n1 &gt; 0 || digit &gt;= 0) { if (digit == -1) Console.Write('.'); n1 &lt;&lt;= 1; if (states.ContainsKey(n1)) { Console.WriteLine(digit &gt;= 0 ? new String('0', digit + 1) : String.Empty); Console.WriteLine("Repeat from digit {0} length {1}.", states[n1], states[n1] - digit); found = true; break; } states.Add(n1, digit); if (n1 &lt; n2) { Console.Write('0'); } else { Console.Write('1'); n1 -= n2; } digit--; } if (!found) { Console.WriteLine(); Console.WriteLine("No repeat."); } } </code></pre> <p>Called with your examples it outputs:</p> <pre><code>.1 No repeat. .01 Repeat from digit -1 length 2. .10 Repeat from digit -1 length 2. 1.0 Repeat from digit 0 length 2. .0011 Repeat from digit -1 length 4. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload