Questions tagged [spigot-algorithm]

Spigot algorithm is used to compute the value of a mathematical constant such as π or e.

A spigot algorithm is a particular type of algorithm used to compute the value of a mathematical constant such as π or e, which can generate a stream of output digits without needing to reuse them.

4 questions
10
votes
3 answers

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)…
Devan Buggay
  • 2,717
  • 4
  • 26
  • 35
4
votes
3 answers

Can anyone make heads or tales of this spigot algorithm code Pitiny.c

This C program is just 143 characters long! But it “decompresses” into the first 10,000 digits of Pi. // Created by cheeseMan on 30/11/13. long a[35014],b,c=35014,d,e,f=1e4,g,h; int main(int argc, const char * argv[]) { for(;(b=c-=14); …
BrianBeaven
  • 173
  • 1
  • 2
  • 11
3
votes
1 answer

JavaScript Pi Spigot Algorithm not working

I have translated the following C++ code: #include using namespace std; #define NDIGITS 100 #define LEN (NDIGITS/4+1)*14 long a[LEN]; long b; long c = LEN; long d; long e = 0; long f = 10000; long g; long h = 0; int main(void) { …
Progo
  • 3,452
  • 5
  • 27
  • 44
0
votes
2 answers

Wrong answer from spigot algorithm

I'm coding the spigot algorithm for displaying digits of pi in ada, but my output is wrong and I can't figure out why I've tried messing with the range of my loops and different ways to output my data but nothings worked properly with…