# Sum evens between 0 and N [duplicate]

## Challenge

Given an integer n, calculate the sum of all even numbers between 0 and n

## Examples

n     output
-------------
100   2550
255   16256
1000  2502500


Shortest code in bytes wins

## marked as duplicate by xnor code-golf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Oct 7 '16 at 1:27

• What are the expected inputs and outputs? What's the winning criterion? Please put them in your question instead of in the tags. Also, I'm fairly sure this is a dupe. – Qwerp-Derp Oct 7 '16 at 1:20
• I closed as a dupe of summing odds. I don't think evens and lack of a lower bound changes much. Be aware that that question was poorly received, likely for being too easy. In the future, I'd suggest running challenge ideas through the sandbox on meta. – xnor Oct 7 '16 at 1:27
• @xnor Fair enough. Though this allows for something much simpler like (n/=2)*n+n. – Geobits Oct 7 '16 at 1:30

(0 to i by 2).sum

val i = (N:Int) => (0 to N by 2).sum