Solution to the rate law of first order reaction followed by second order reaction (consecutive)
The  following code is in Python and uses numpy, scipy and matplotlib that are usually packaged with python.  The code will solve the equations $\mathrm{A} \underset{k_3}{\stackrel{k_1}\leftrightharpoons}  2\mathrm{B} \stackrel{k_2} \longrightarrow \mathrm{ P}$ but you can set $k_3$ to zero if you want. (its called km1 in the code). I've used log time spaced points so that a wide time range can be seen. The x axis is log in the plots.

I have used a built in solver, odeint(), buy you could write your own based on the Euler or Runge -Kutta methods. 

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint

def dX_dt(X, t, const):     # returns rates dEf/dt, only used in odeint()

    k1, km1, k2 = const     # unpack constants needed for calc'n
    A = X[0] 
    B = X[1] 
    dAdt=    -k1*A  +  km1*B*B                 #  rate equations here 
    dBdt=     k1*A  - (km1+k2)*B*B

    f = np.array( [(dAdt), (dBdt)] )           # evaluate equations; 
    return f

C0 = np.zeros(2,dtype=float)
C0[0] = 1.0e-3    # C0= [ A(0), B(0)   ]      # initial concentrations 
numt = 200
t = np.logspace( -9,-4,  numt )    # time as initial power, final power, num points
k1  = 1e7  # 1st order rate const s^(-1)
km1 = 1e6  # 2nd dm^3mol^(-1)s^(-1)
k2  = 1e9  # 2nd  ....
const = [ k1, km1, k2 ]                            # rate constants for calc'n

soln = odeint(dX_dt, C0, t, args = (const,)  )     # solve equations                 
Aval, Bval = soln.T     # extract data

plt.plot(t,Aval,color='red',  label='A')
plt.plot(t,Bval,color='green',label='B')
plt.plot(t,C0[0]-Aval-Bval,color='blue',label='P')
plt.xscale('log')
plt.legend()

plt.tight_layout()
plt.show()


The figure shows the populations vs (log) time