📜  数学 |偶数和奇数自然数的平方和

📅  最后修改于: 2021-09-28 10:04:57             🧑  作者: Mango

我们知道前 n 个自然数的平方和是\frac{n(n+1)(2n+1)}{6} .

如何计算前n个偶数自然数的平方和?
我们需要计算 2 2 + 4 2 + 6 2 + …。 + (2n) 2

EvenSum = 22 + 42 + 62 + .... + (2n)2 
        = 4 x (12 + 22 + 32 + .... + (n)2)
        = 4n(n+1)(2n+1)/6
        = 2n(n+1)(2n+1)/3

例子:

Sum of squares of first 3 even numbers =
                 2n(n+1)(2n+1)/3
               = 2*3(3+1)(2*3+1)/3
               = 56
22 + 42 + 62 = 4 + 16 + 36 = 56

如何计算前n个奇数自然数的平方和?
我们需要计算 1 2 + 3 2 + 5 2 + …。 + (2n-1) 2

OddSum  = (Sum of Squares of all 2n numbers) - 
          (Sum of squares of first n even numbers)
        = 2n*(2n+1)*(2*2n + 1)/6 - 2n(n+1)(2n+1)/3
        = 2n(2n+1)/6 [4n+1 - 2(n+1)] 
        = n(2n+1)/3 * (2n-1)
        = n(2n+1)(2n-1)/3

例子:

Sum of squares of first 3 odd numbers = n(2n+1)(2n-1)/3
                                      = 3(2*3+1)(2*3-1)/3
                                      = 35
12 + 32 + 52 = 1 + 9 + 25 = 35