figure;
subplot(2,1,1)
p = 0.99;
k = 0:1000;
geomSeries = p.^k;
Sum1 = cumsum(geomSeries);
Sum2 = 1/(1-p);
plot(k,Sum1,k,Sum2,'r');
ylim([0 120]);
xlabel('k');
ylabel('SerieValues')
title('Geometric serie Convergence');
legend('Infinite Sum','Finite Sum');

subplot(2,1,2)
p = 2;
n = 1:500;
pSeries = 1./n.^p;
Sum1 = cumsum(pSeries);
Sum2 = pi^2/6;
plot(n,Sum1,n,Sum2,'r');
xlabel('n');
ylabel('SerieValues')
title('PSerie Convergence');
legend('Infinite Sum','Finite Sum');