Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't think it's possible in the general case. If <code>m</code> is a power of <code>p</code> (or vice-versa), or if they're both powers of a common base, you can do it, since each group of log<sub><code>m</code></sub>(<code>p</code>) is then independent. However, in the general case, suppose you're converting the number <code>a</code><sub><code>1</code></sub> <code>a</code><sub><code>2</code></sub> <code>a</code><sub><code>3</code></sub> <code>...</code> <code>a</code><sub><code>n</code></sub>. The equivalent number in base <code>p</code> is</p> <p><code>sum(a</code><sub><code>i</code></sub> <code>*</code> <code>m</code><sup><code>i-1</code></sup> for <code>i</code> in <code>1..n)</code></p> <p>If we've processed the first <code>i</code> digits, then we have the <code>i</code>th partial sum. To compute the <code>i+1</code>'th partial sum, we need to add <code>a</code><sub><code>i+1</code></sub> <code>* m</code><sup><code>i</code></sup>. In the general case, this number is going have non-zero digits in most places, so we'll need to modify all of the digits we've processed so far. In other words, we'll have to process <em>all</em> of the input digits before we'll know what the final output digits will be.</p> <p>In the special case where <code>m</code> are both powers of a common base, or equivalently if log<sub><code>m</code></sub>(<code>p</code>) is a rational number, then <code>m</code><sup><code>i</code></sup> will only have a few non-zero digits in base <code>p</code> near the front, so we can safely output most of the digits we've computed so far.</p>
 

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