import std.math, std.algorithm, std.range; auto r1 = iota(500).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a)); auto r2 = iota(500, 1000).map!(a => 1.7L.pow(a+1) - 1.7L.pow(a)); Summator!real s1 = 0, s2 = 0.0; foreach (e; r1) s1 += e; foreach (e; r2) s2 -= e; s1 -= s2; s1 -= 1.7L.pow(1000); assert(s1.sum() == -1);
Operator overloading.