|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
The VERY fast pi calculator compare to any other ones ever made in PHP. On my machine, this can easily find the 1000th decimal place of pi in 5 seconds
Read though and see an example of how it works
| <?
//Pi calculation code
//From Chao Xu
//At http://www.webdevlogs.com
function bcpi($precision){
$num = 0;$k = 0;
bcscale($precision+3);
$limit = ($precision+3)/14;
while($k < $limit){
$num = bcadd($num,bcdiv(bcmul(bcadd('13591409',bcmul('545140134', $k)),bcmul(bcpow(-1, $k), bcfact(6*$k))),bcmul(bcmul(bcpow('640320',3*$k+1),bcsqrt('640320')), bcmul(bcfact(3*$k), bcpow(bcfact($k),3)))));
++$k;
}
return bcdiv(1,(bcmul(12,($num))),$precision);
}
function bcfact($n){
return ($n == 0 || $n== 1) ? 1 : bcmul($n,bcfact($n-1));
}
?> | |
Usage Example
| echo bcpi(30);
//out put 30 places of pi | | |
|
| BCrand, a function returns large random numbers Categories : PHP, BC math, Algorithms | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Boolean Keyword Interpreter Categories : PHP, Algorithms, Search Engines | | | Diffusion-Limited Aggregation visualization Categories : PHP, Graphics, Algorithms, Math. | | | bcadd -- Add two arbitrary precision numbers Categories : PHP, PHP Functions, BC math | | | Browse a MySQL database & draw a tree view & load final items into a template page. Categories : MySQL, Complete Programs, Algorithms, PHP, Databases | | | Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms | | | calculus of the eastersunday Categories : BC math, PHP, Date Time, Databases | | | Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users). Categories : Algorithms, Email, PHP | | | A recursive function to traverse a multi-dimensional array where the
dimensions are not known Categories : Arrays, PHP, Algorithms | | | The Porter Word Stemming Algorithm in PHP
Reduces words to their base stem for search engines and indexing Categories : Algorithms, PHP, Strings | | | SHA: Implementation of the Secure Hash Algorithm in pure PHP. This is a secure one-way function that can be used to perform challenge
response login algorithms over an insecure connection. Categories : Algorithms, PHP, Security | | | minus - subtract arrays. Send two arrays and get an array with the operation A-B, elements on A that are not included on B. Categories : PHP, Arrays, Algorithms | | | Calculate Body Mass Index Categories : PHP, Algorithms, Regexps | |
|
|
|