Tính tổng S=1-2+3-4+5-6....-100 S=1+1/2+.......+1/n S2=1+1/2+.......+1/N! S3=1+x+x^2/2!+x^3/3!+.....

2 câu trả lời

Bài s=1+1/2+1/3+...+1/n đây nha

S=1-2+3-4+5-6....-100

uses crt;
var i,n,k,s:longint; 
begin
clrscr;
   write('Nhap n: ');readln(n);
   k:=-1;
   for i:=1 to n do 
      begin
         k:=k*-1;
         s:=s+k*i;
      end;
   writeln('S=',s);
readln
end.

S=1+1/2+.......+1/n

uses crt;
var i,n:longint; s:real;
begin
clrscr;
   write('Nhap n: ');readln(n);
   for i:=1 to n do s:=s+1/i;
   writeln('S=',s:0:5);
readln
end.

S2=1+1/2+.......+1/N!

uses crt;
var i,n,gt:longint; s:real;
begin
clrscr;
   write('Nhap n: ');readln(n);
   gt:=1;
   for i:=1 to n do 
      begin
         gt:=gt*i; 
         s:=s+1/gt;
      end;
   writeln('S2=',s:0:5);
readln
end.
S3=1+x+x^2/2!+x^3/3!+...

uses crt;
var i,n,gt,lt,x:longint; s:real;
begin
clrscr;
   write('Nhap n,x: ');readln(n,x);
   gt:=1; lt:=1; s:=1;
   for i:=1 to n do 
      begin
         gt:=gt*i; lt:=lt*x;
         s:=s+lt/gt;
      end;
   writeln('S3=',s:0:5);
readln
end.