All pastes #929927 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-06 04:00 UTC
rendered paste body
#include <stdio.h>
#include <math.h>
#define PI 3.1415927
 
int main (void)
{
        float input, i;
 
        printf("Enter a number: ");
        scanf("%f",&input);
        double solution = input;
        double last_term = input;
        double term;
        
        for (i = 1; i < 100; i++) {   
            term = last_term * (pow(input,2) * (2*i - 1))/((2*i + 1) * i) * -1;
            solution = solution + term;
            last_term = term;
        }  
        
        solution = solution * 2/(sqrt(PI));     
        printf("Solution = %f \n", solution);        
        return 0;
}