Comunidade SEED

Building with Bricks

Versão para impressãoVersão para impressão

To solve the problem we can use a pyramid with H={1, 2,3} and then we see that the amount of bricks needed to build a pyramid with height H is equal to H2.

Mathemathical proof:

f(1) = 1;

f(x) = f(x-1) + 2*x - 1 for x > 1

Where f(x) is number of bricks needed to build the pyramid with height x.

x2- (x-1)2= (x-(x-1))*(x+(x-1)) = 2*x - 1;

f(1) = 1 = 12, then f(2) =  (2-1)2+ 2*x - 1 = 4 = 22, so f(x) = x2

So f(5) = 25 and f(10) = 100

1.5
Sua pontuação: Nenhum Média: 1.5 (2 votos)