3GPP defines a pseudo-random sequence (PN sequence)  generator that uses a length-31 Gold Sequence. This sequence generator is used to scramble many signals before transmission. 3GPP TS 38.211 Section 5.2.1 defines how to generate the scrambling sequence $c(n)$ for a sequence of length $M_{PN}$. The sequence generator accepts two parameters:

1) $M_{PN}$: the length of the sequence to generate

2) $c_{init}$: the initial condition to seed the second m-sequence $x_2$

First, two m-sequences (maximum length sequences of a linear-feedback shift register) are defined. The first 31 elements of the m-sequences are initialized as follows

$x_1(0) = 1$, $x_1(n)=0$ for n = 1,...,30

$c_{init} = \Sigma_{i=0}^30 x_2(i) * 2^i$

In practice this means that each bit of the 32-bit number $c_init$ is a value in the $x_2$ sequence so that you can initialize $x_2(n)$ with the least significant bit of $c_{init}$ shifted right right by $n$.

$ x_1(n+31) = (x_1(n+3) + x_1(n)) % 2 $
$ x_2(n+31) = (x_2(n+3) + x_2(n+2) + x_2(n+1) + x_2(n)) % 2 $

The actual PN sequence being generated ($c_n$) uses these m-sequences offset by $N_c=1600$ using the following formulation

$c(n) = (x_1(n+N_c) + x_2(n+N_c)) % 2$

Depending on the implementation $x_1$ and $x_2$ can either be implemented as shift registers or the sequences can be stored with all history. A naive python implementation is

def gen_gold(M_pn, c_init, N_c=1600):
    x_1 = np.zeros(N_c + M_pn + 31)
    x_2 = np.zeros(N_c + M_pn + 31)
    x_1[0] = 1

    for nn in range(31):
        x_2[nn] = (c_init >> nn) % 2

    print x_2[0:31]
    for nn in range(0, N_c+M_pn):
        x_1[nn+31] = (x_1[nn+3] + x_1[nn]) % 2
        x_2[nn+31] = (x_2[nn+3] + x_2[nn+2] + x_2[nn+1] + x_2[nn]) % 2

    c = np.zeros(M_pn)
    for nn in range(M_pn):
        c[nn] = (x_1[nn+N_c] + x_2[nn+N_c]) % 2

    return c

This is the same gold sequence generator used in previous 3GPP releases and LTE. srsLTE provides a C implementation (https://github.com/srsLTE/srsLTE/blob/master/lib/src/phy/common/sequence.c#L88).