#include int main(int argc, char *argv[]) { int p, q, d; int j, tot = 0; int k, t, a[100000]; int num; char o[1]=""; principio: k = 4000; t = 1000; printf("\n\nInput number of decimals desired: "); scanf(" %i", &tot); if (tot%3 != 0) tot++; printf("\n\n\tPI = 3,"); num=(tot/3) + 3; while(k > 1) { k--; q = 0; a[0] += 2; p = 1 + 2 * k; for(j = 0; j < num; j++) { if((j > 2 && k == 1) || k == 0) { d = a[j - 2]%t + (q / p) / t; printf("%.3ld",d); } q = a[j] * k + q%p * t; a[j] = q / p; } } tot = (num-3) * 3; printf("\n\n\tNumber of decimals: %i", tot); printf("\n"); printf("\n\tWanna try again? (y/n): "); scanf(" %c", &o); if (o[0]=='y') goto principio; printf("\n\n"); return 0; }