# [Python](https://www.python.org), 116 bytes Takes input a decimal number as a string, while using a recursive [function][1] to calculate the first `n` primes and the proposed equation of user `GotCubes`. ```python f=lambda n,i=1,p=1:n*[0]and p%i*[i]+f(n-p%i,i+1,p*i*i) c=lambda s:sum(y*(9-x)for x,y in zip(map(int,s),f(len(s))))+1 ```` [Attempt This Online!](https://ato.pxeger.com/run?1=NY9NCoMwEIX3niKb4iRGMIqigtB7iAurDR3QMfgD2qt046a9U29TbetbfYvvvWEeL7OMt47W9TmN2o3fo86asr3UJSOJmZImUymJ3CtKqpk5ocixcDSQu7FEZxMECuRWddSGdJhaWAQk7sx117NZLgyJ3dFAWxpAGuXApYbmSjDwLY763z7vOu1ybvsqsCWz4ySM1A7JNzuFgR95cRD6dpFajJl-W4QKiHPrt3P88gE) [1]: https://codegolf.stackexchange.com/a/152433/110265