# CHESS1 - Editorial

Practice

Contest

Author: Md Shahid

Tester: Arkapravo Ghosh

Editorialist: Md Shahid

SIMPLE

### PROBLEM:

Given N.You need to find the number of possible squares in N x N chess board.

### EXPLANATION:

In this problem you have to count total numbers of all possible squares in the given N X N grid chess.

Total number of square in 1 X 1 chess = 1.

Total number of square in 2 X 2 chess = 5.

Total number of square in 3 X 3 chess = 14.

Can you see a pattern in the above three lines?

Yes.

Total number of square in 1 X 1 chess = 1 = 1^2.

Total number of square in 2 X 2 chess = 5 = 1^2 + 2^2.

Total number of square in 3 X 3 chess = 14 = 1^2 + 2^2 + 3^2.

.

.

.

Total number of squares in N X N chess = 1^2 + 2^2 + 3^2 + . . . . . . . . + N^2

As we know from algebra,

1^2 + 2^2 + 3^2 + . . . . . . . . + N^2 = (N(N+1)(2N+1))/6

``````Input N
Sum = (N(N+1)(2N+1))/6
print Sum
``````

### AUTHOR’S, TESTER’S AND EDITORIALIST’S SOLUTIONS:

Author’s and editorialist’s solution can be found here.
Tester’s solution can be found here.

Tags:- ENCODING CHESS1 dshahid380