Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double sum_pi(int n) {
- return (pow((-1),n))/((2*n)+1);
- }
- double pinto(int tamanho){
- double r = 0;
- for (int c=0; c<=tamanho; c++){
- r += sum_pi(c);
- }
- return(4*r);
- }
- double factorial(int n) {
- double result = 1.0;
- for (int c; c <= n; c++) {
- result *= c;
- }
- return result;
- }
- double sum_e(int x, int n){
- double result = (pow(x,n))/factorial(n);
- return result;
- }
- void e(int x){
- cout << exp(x) << endl;
- double result = 0;
- for (int c = 1; c <= 100; c++){
- result += sum_e(x,c);
- cout << result << " | ";
- if (!(c % 10)){
- cout << endl;
- }
- }
- }
- int main(){
- while(true){
- cout << "Type qualquer porra: ";
- long int tamanho;
- cin >> tamanho;
- e(tamanho);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement