S=1+x+x^2+x^3+x^4+...+x^n-1+x^n. S>=10000 ai giúp mình với
2 câu trả lời
uses crt;
var n,i,x,t:longint; s:real;
begin
clrscr;
write('x=');readln(x);
while s<10000 do
begin
t:=1;
for i:=1 to n do t:=t*x;
s:=s+t;
inc(n);
end;
writeln('n= ',n-1);
writeln('s= ',s:0:0);
readln
end.
program tinhtong;
uses crt;
var s,gt:longint;
x,n,i:integer;
begin
clrscr;
write('Nhap x: '); readln(x);
s:=0; n:=0;
while s<10000 do
begin
gt:=1;
for i:=1 to n do
gt:=gt*x;
s:=s+gt;
n:=n+1;
end;
writeln('Tong nho nhat thoa man la: ',s);
writeln('Va so n nho nhat thoa man la: ',n);
readln
end.