Lap trinh tinh tong A= 1 + 1/2 +1/3+-+1/n voi n nhap tu ban phim hua vote 5 sao :3

Lap trinh tinh tong
A= 1 + 1/2 +1/3+….+1/n
voi n nhap tu ban phim
hua vote 5 sao :3

0 bình luận về “Lap trinh tinh tong A= 1 + 1/2 +1/3+-+1/n voi n nhap tu ban phim hua vote 5 sao :3”

  1. #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        double n,total=0;
        cin>>n;
        for(int i=1;i<=n;i++){
            total+=1/(float)i;
        }
        cout<<total;
        //samon247
        return 0;
    }

    Bình luận
  2. program oken;

    uses crt;

    var a: real;

    i,n:longint;

    begin

    clrscr;

    write(‘nhap n: ‘); readln(n);

    a:=0; i:=1;

    while i<=n do

    begin

    a:=a+1/i;

    i:=i+1;

    end;

    writeln(‘A=’,a:0:3);

    readln;

    end.

    Bình luận

Viết một bình luận