All pastes #929902 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-06 03:15 UTC
rendered paste body
#include <stdio.h>
#include <math.h>
#define PI 3.1415927

int main (void)
{
        int input, i;
 
        printf("Enter a number: ");
        scanf("%i",&input);
        float solution = input;
        float last_term = input;
        float 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;
}