# Method 3a: the vaguely Mathematica-ish way $sum = 0 + join('+', N..M);