Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int fact(int n)
- {
- if(n==0)return 1;
- else return n*fact(n-1);
- }
- double exp(int x,float eps)
- {
- int i=0;
- float exp=0;
- while(pow(x,i)/fact(i)>eps){
- exp=exp+pow(x,i)/fact(i);
- i++;
- }
- return exp;
- }
- int main()
- {
- float x,eps;
- cout << "Podaj x: ";
- cin>>x;
- cout<<"Podaj eps: ";
- cin>>eps;
- cout<<exp(x,eps);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement