Skip to content
/ pigeon Public

π generator using Jeremy Gibbons' Spigot Algorithm.

License

Notifications You must be signed in to change notification settings

xr1s/pigeon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pigeon

This program is a π generator using Jeremy Gibbons' Spigot Algorithm. See the Jeremy Gibbons' paper in directory paper.

Requirement

  • A C++ compiler support C++11.
  • GMP (GNU Multiple Precision Arithmetic Library)

Demo

For calculating exactly 1023 digits after the decimal point:

#include <iostream>
#include "pigeon.hh"
int main() {
  for (long pi: pigeon(1024))  // includes leading 3
    std::cout << pi << std::flush;
}

For calculating infinitely:

#include <iostream>
#include "pigeon.hh"
int main() {
  for (long pi: pigeon())
    std::cout << pi << std::flush;
}

This is not infinite, to be honest. But I believe deeply that no one can successfully calculate 18446744073709551615 (on 64 bits machine) digits after decimal point before memory runs out, or time.

About

π generator using Jeremy Gibbons' Spigot Algorithm.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages