Fusc sequence: Difference between revisions

Content added Content deleted
(Frugal version)
Line 3,282: Line 3,282:
===Frugal version===
===Frugal version===
Based on Mike Stay's formula, this program does not need recursion or storage of n/2 previous terms, and is faster.
Based on Mike Stay's formula, this program does not need recursion or storage of n/2 previous terms, and is faster.
Since <code>fusc(2^n)=1</code> and <code>fusc(2^n+1)=n+1</code>, this formula can improve the calculation for big values of n, as the iteration can start at floor(log2(n)) instead of 1.
Since <code>fusc(2^n)=1</code> and <code>fusc(2^n+1)=n+1</code>, this formula can seriously improve speed for big values of n, as the iteration could start at <code>2^floor(log2(n))</code> instead of 2.
{| class="wikitable"
{| class="wikitable"
! RPL code
! RPL code