This is the Q&A placeholder for answers to be posted. Once you have a solution for the challenge, post your answer/solution in the comments below. Thanks, and I hope you enjoy the challenge!
DANGIT @gilliek! I was trying to force a list comprehension yesterday but it was not having my += business. Thanks for expanding my toolkit with sum, that’s handy. And simple, I love how readable python can be.
sum (1 -> x) = (x*(x+1))/2
sum even (if x is even) (1 -> x) = (x/2*(x/2 +1)
sum odd (1-> x) = (x*(x+1))/2 - (x/2*(x/2 +1))
= x/2 * ((x+1) - (x/2 +1))
= x/2 * (x - x/2)
the tcl code is :
% set x 4976
4976
to convert odd to next even number if number is odd
%set x [expr {($x-1)/2*2+2}]
4976
%set result [expr {$x/2 * ($x - $x/2) }]
6190144