4 ms·
or sum(range(366))
by tome 17y ago
or
sum(range(366))
- deleted 17y ago[deleted]
- Torn 17y agodidn't even think of that one! :)
- karanbhangui 17y agoor plain math: n(n+1)/2
- mahmud 17y agoHow quickly can you generalize the plain math formula to these sequences: http://www.research.att.com/njas/sequences/index.html http://www.research.att.com/njas/sequences/index.html
- deleted 17y ago[deleted]
- mahmud 17y ago(sum (range 1 365)) assuming you defined these already; I have them in my utils library ;-) (defun range (start end) (loop for x from start to end collecting x)) (defun sum (sequence) (reduce #'+ sequence))