Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Given an integer n, calculate the sum of all even numbers between 0 and n
Shortest code in bytes wins
shortest I could figure:
(0 to i by 2).sum
Using an anonymous function:
val i = (N:Int) => (0 to N by 2).sum