c# Efficient solution: Sequence generator for a pattern
public static void GenerateSequence() {
    double tenPower(double n) =&gt; Math.Pow(10, Math.Floor(Math.Log10(n)+1));
    double build(double n) =&gt; n * tenPower(n + 1) + n + 1;
    double merge(double n1, double n2) =&gt; n1 + n2 / tenPower(n2);

    var n = 1;
    var ans = new double[16];
    for (int j1 = 0; j1 &lt; 16; ++j1) {
        n += j1;

        var whole = build(n);
        var frac = build(n + 2);
        ans[j1] = merge(whole, frac);
    }
    
    foreach (var a in ans)
        Console.WriteLine(a);
}