Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- int N = 0;
- do {
- cout << "Upisite N :D \n";
- cin >> N;
- }while(N < 1);
- if(N == 1) {
- cout << 1;
- return 0;
- } else if (N == 2) {
- cout << 2;
- return 0;
- }
- double e = 2;
- double nesto = 2;
- for(int i = 0; i < N-2 ; ++i) {
- nesto = 1;
- for(int j = 1; j <= i+2; ++j)
- nesto *= j;
- e += (1/nesto);
- }
- cout << setprecision(12) << e;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment