Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}$)?


share|cite|improve this question
You are probably overflowing... – soandos Jun 12 '11 at 22:00
According to 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$. – Américo Tavares Jun 12 '11 at 22:23
For a definition of Golomb sequence and the asymptotics mentioned in the post, – Did Jun 13 '11 at 7:57
python easily handle big ints, so i don't think this is the reason. Difference between big numbers as 10^9 is ~100. – Spinach Jun 13 '11 at 14:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.