nlast=5;sum=0;
x=0.5;
Do[ 
sum=sum+x^n;
(*Print[{n,sum}];*)
record=n;
,{n,0,nlast}];
Print[sum];

nlast=50;summ=0;x=0.175;
For[n=0,n≤nlast,n++,
summ=summ+x^n;
(*Print[{n,x^n,summ}]*)
];
Print[summ]

f[x_]:=1/(1-x);
Plot[f[x],{x,0.01,0.99}]

nlast=10;sum=0;
For[n=0,n≤nlast,n++,
sum=sum+x^n;
];
series[xdummy_]:=sum/.{x->xdummy}

Plot[{f[xdummy],series[xdummy]},{xdummy,0.01,0.99}]

f[x_]:=1/(1-x);
sum=0;nlast=50;
For[n=0,n≤nlast,n++,
sum=sum+x^n
];
series[xdummy_]:=sum/.{x->xdummy};
Plot[{f[x],series[x]},{x,-1.2,1.5},
PlotStyle->{Red,Black}
]