2 câu trả lời
#include<bits/stdc++.h>
using namespace std;
int giaithua(int n)
{
int total=1;
for(int i=1;i<n;i++){
total*=i;
}
return total;
}
int main()
{
float n,total=0;
cin>>n;
for(float i=1;i<n;i++){
total+=1/(float)giaithua(i);
}
cout<<total;
//samon247
return 0;
}
uses crt;
var n : integer;
function gt( K : integer) : real;
var i,j,s : integer;
m : real;
begin clrscr;
for i:=1 to n do begin s:=1;
for j:=1 to i do s:=s*j;
m:=m+1/s end;
gt:=m;
end;
begin clrscr;
write('Nhap n:'); readln(n);
write('Tong do la :', gt(n):2:3);
readln
end.
Câu hỏi trong lớp
Xem thêm