For the 12.1*10^12 calculation the refernced web site says:
Hudnovsky algorithm [1] for the calculation, Bellard BBP formula for verification. Implementation in the programm y-cruncher "A Multi-Threaded Pi-Programy-chruncher" [3]
For the math see [4] also.