1
$\begingroup$

How to compute $n$-th element in golomb's sequence? I've found that $A_n$ is approximately: $$\phi^{2-\phi} * n^{\phi-1},\;\; \text{ where }\;\; \phi \;\;\text {is golden ratio}.$$

As far as I checked with my python and C++ program it gives right answers for low numbers, but for high numbers like $10^9$ or $10^{18}$ it's totally wrong.

Is there another solution without computing so many numbers (even to $10^{18}$)?

Chris

  • 1
    You are probably overflowing...2011-06-12
  • 2
    According to [A001462](http://oeis.org/A001462) $a(n)=\varphi ^{2-\varphi }n^{\varphi -1}+E(n)$, where $E(n)$ is $O(n^{\varphi -1}/\log n)$. This means that $\frac{a(n)}{\varphi ^{2-\varphi }n^{\varphi -1}}=1+O\left( \frac{% 1}{\log n}\right) \rightarrow 1$.2011-06-12
  • 1
    For a definition of Golomb sequence and the asymptotics mentioned in the post, http://en.wikipedia.org/wiki/Golomb_sequence2011-06-13
  • 0
    python easily handle big ints, so i don't think this is the reason. Difference between big numbers as 10^9 is ~100.2011-06-13

0 Answers 0