giúp mình với (Pascal) tính tổng S=2!+4!+6!+…+(2n)! (dùng repeat until ) 04/08/2021 Bởi Raelynn giúp mình với (Pascal) tính tổng S=2!+4!+6!+…+(2n)! (dùng repeat until )
Program NhatNgu;Uses crt;Var n,i: byte; s: qword; Function gt(a: byte): qword;Begin If (a=0) or (a=1) then gt:=1 else gt:=a*gt(a-1);End; Begin Clrscr; Write(‘Nhap n: ‘); Readln(n); s:=0; i:=1; Repeat Begin s:=s+gt(2*i); inc(i); End; Until i>n; Write(‘S = ‘,s); ReadlnEnd. Bình luận
uses crt;var t,n,d:longint;function gt(x:longint):longint;var i:longint;begingt:=1;for i:=1 to x do gt:=gt*i;end;beginclrscr;write(‘Nhap n=’);readln(n);d:=0; t:=0;repeat d:=d+2; t:=t+gt(d);until d=(2*n);writeln(‘s=’,t);readln;end. Bình luận
Program NhatNgu;
Uses crt;
Var n,i: byte;
s: qword;
Function gt(a: byte): qword;
Begin
If (a=0) or (a=1) then gt:=1 else gt:=a*gt(a-1);
End;
Begin
Clrscr;
Write(‘Nhap n: ‘); Readln(n);
s:=0; i:=1;
Repeat
Begin
s:=s+gt(2*i);
inc(i);
End;
Until i>n;
Write(‘S = ‘,s);
Readln
End.
uses crt;
var t,n,d:longint;
function gt(x:longint):longint;
var i:longint;
begin
gt:=1;
for i:=1 to x do gt:=gt*i;
end;
begin
clrscr;
write(‘Nhap n=’);readln(n);
d:=0; t:=0;
repeat
d:=d+2;
t:=t+gt(d);
until d=(2*n);
writeln(‘s=’,t);
readln;
end.