#P8676. Golomb Sequence

    ID: 21842 Type: Default 1000ms 256MiB

Golomb Sequence

Golomb Sequence

The Golomb Sequence is a self-descriptive sequence denoted by \(G(n)\) with two interesting properties:

  • For every positive integer \(n\), the number \(n\) appears exactly \(G(n)\) times in the sequence.
  • The sequence is non-decreasing.

For example, the first several values are given in the table below:

n12345678910111213
\(G(n)\)1223344455566

Given an integer \(n\), compute \(G(n)\).

inputFormat

The input consists of a single integer \(n\) on one line.

outputFormat

Output the value of \(G(n)\) for the given input \(n\).

sample

1
1

</p>