We know sum squares of first n natural numbers is .

**How to compute sum of squares of first n even natural numbers?**

We need to compute 2^{2} + 4^{2} + 6^{2} + …. + (2n)^{2}

EvenSum = 2^{2}+ 4^{2}+ 6^{2}+ .... + (2n)^{2}= 4 x (1^{2}+ 2^{2}+ 3^{2}+ .... + (n)^{2}) = 4n(n+1)(2n+1)/6 =2n(n+1)(2n+1)/3

**Example:**

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

**How to compute sum of squares of first n odd natural numbers?**

We need to compute 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

Example:

Sum of squares of first 3 odd numbers = n(2n+1)(2n-1)/3 = 3(2*3+1)(2*3-1)/3 = 35 1^{2}+ 3^{2}+ 5^{2}= 1 + 9 + 25 = 35

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- DFA machines accepting odd number of 0’s or/and even number of 1’s
- Mathematics | Predicates and Quantifiers | Set 1
- Mathematics | Mean, Variance and Standard Deviation
- Mathematics | Eigen Values and Eigen Vectors
- Mathematics | Introduction and types of Relations
- Mathematics | Representations of Matrices and Graphs in Relations
- Mathematics | Covariance and Correlation
- Mathematics | Predicates and Quantifiers | Set 2
- Mathematics | Closure of Relations and Equivalence Relations
- Mathematics | Partial Orders and Lattices
- Mathematics | Graph Isomorphisms and Connectivity
- Mathematics | Planar Graphs and Graph Coloring
- Mathematics | Euler and Hamiltonian Paths
- Mathematics | PnC and Binomial Coefficients
- Mathematics | Limits, Continuity and Differentiability
- Mathematics | Walks, Trails, Paths, Cycles and Circuits in Graph
- Mathematics | Power Set and its Properties
- Mathematics | Unimodal functions and Bimodal functions
- Mathematics | Sequence, Series and Summations
- Mathematics | Independent Sets, Covering and Matching