The first four figures of a pattern are shown below. How many squares would be needed to build the nth figure?

Answer:
[tex]2n^2-2n+1[/tex]
Step-by-step explanation:
let ‘n’ be the number of the figure.
For n = 2 :
The number of the squares of the second figure :
= (the number of the squares of the middle/horizontal row) + (the number of the remaining squares)
= (2×2−1) + 2×(1+2×0)
= (3) + 2×(1)
= 3 + 2
= 5
For n = 3 :
The number of the squares of the third figure :
= (the number of the squares of the middle/horizontal row) + (the number of the remaining squares)
= (2×3−1) + 2×[(1+2×0) + (1+2×1)]
= (5) + 2×[(1) + (3)]
= 5 + 2×[4]
= 5 + 8
= 13
For n = 4 :
The number of the squares of the fourth figure :
= (the number of the squares of the middle/horizontal row) + (the number of the remaining squares)
= (2×4−1) + 2×[(1+2×0) + (1+2×1)+ (1+2×2)]
= (7) + 2×[(1) + (3) + (5)]
= 7 + 2×[9]
= 7 + 18
= 25
For n (n ≥ 2) :
The number of the squares of the nth figure :
= (the number of the squares of the middle/horizontal row) + (the number of the remaining squares)
[tex]= (2n-1) +2\times \left( \sum^{n-2}_{k=0} \left( 1+2k\right) \right)[/tex]
[tex]= (2n-1) +2\times \left( \sum^{n-2}_{k=0} \left( 1\right) \right)+4\times \left( \sum^{n-2}_{k=0} \left( k\right) \right)[/tex]
[tex]= (2n-1) +2(n-1)+4\times [\frac{n-1}{2}(0+(n-2))][/tex]
[tex]= (2n-1) +(2n-2)+4\times [\frac{n-1}{2}(n-2)][/tex]
[tex]= 4n-3+2\times (n-1)(n-2)[/tex]
[tex]= 4n-3+2\times (n^2-3n+2)[/tex]
[tex]= 4n-3+2n^2-6n+4[/tex]
[tex]= 2n^2-2n+1[/tex]