【发布时间】:2018-03-20 11:22:36
【问题描述】:
我必须对 1 和 ' n '(包括)之间的偶数求和。例如对于 n = 5 程序返回 6(2+4)。如何制作?
【问题讨论】:
-
欢迎来到 stackoverflow.com。请花一些时间阅读the help pages,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。也请take the tour 和read about how to ask good questions。最后请学习如何创建Minimal, Complete, and Verifiable Example。
-
select sum(i) from generate_series(1,5) as t(i) where i % 2 = 0 -
sum(first n even numbers) = n * (n+1)