• + 2 comments

    I did it using a simple loop and I don't even know what DP is. Could you please show me what a solution using DP looks like?

    function main() {
        let [a, b, n] = input.split(' ').map(Number);
        a = new BigNumber(a);
        b = new BigNumber(b);
        for (let i = 3; i <= n; i++) {
            var c = next(a, b);
            a = b, b = c;
        }
        process.stdout.write(c.toFixed());
    }