Implementing the Spigot algorithm for π (pi)
问题 I'm having a hard time understanding the Spigot algorithm for π (pi) found here at the bottom of the page. I'm getting lost at the bottom of part 2 "Put A into regular form", I'm not exactly sure how to implement this in C (or any language really) 回答1: #include <math.h> #include <stdio.h> #define N 100 int len = floor(10 * N/3) + 1; int A[len]; for(int i = 0; i < len; ++i) { A[i] = 2; } int nines = 0; int predigit = 0; for(int j = 1; j < N + 1; ++j) { int q = 0; for(int i = len; i > 0; --i) {