Skip to content

Instantly share code, notes, and snippets.

@RezaBidar
Created June 28, 2015 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RezaBidar/d2e5b9e9fddb4b929c77 to your computer and use it in GitHub Desktop.
Save RezaBidar/d2e5b9e9fddb4b929c77 to your computer and use it in GitHub Desktop.
for davood mirzaii
#include<iostream>
using namespace std ;
int fact(int x){
if(x == 0) return 1 ;
return x * fact(x-1);
}
int main(){
int n ;
float e = 0 ;
cin >> n ;
for(int i = 0 ; i <= n ; i++){
e += 1.0 / (float)fact(i) ;
}
cout << e ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment