math - Bailey-Borwein-Plouffe in php trouble -


i trying implement bbp algorithm in php. code returning decimal thought odd should in hex. told convert decimal hex multiplying 16 wrong. here sample:

$n1=$n2=$n3=$n4=$n5=$n6=$n7=$n8 =0; $s1=$s2=$s3=$s4=$s5=$s6=$s7=$s8 = 0; //initializing $k = 0; $m1=  8*$k + 1; $m2 = 8*$k + 4; $m3 = 8*$k + 5; $m4 = 8*$k = 6;  $b =16; $e=$n-$k;   while($k<$n){ //sum 1 of 8      $s1 +=modular($b, $m1, $e)/$m1; //see moduler_expansion.php     $k++;  }  $k = $n +1; //redefine second sum, , every other while($k<$limit){ //sum 2 of 8      $s2 += (pow($b,$n-$k))/($m1);     $k++; //now repeat similar process each sum. } 

and repeat process each term of bbp then:

$s = 4*($s1 + $s2) - 2*($s3+$s4) -($s5+$s6) - ($s7+$s8); 

` following wiki page strip integer , multiply 16, $k =0 get; 3.4977777777778 , $k = 1: 7.9644444444448.

i dont think these right, not know how interpret th ouput properly. can offer advice?


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -