Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Jensens-Device/PHP/jensens-device.php
Normal file
24
Task/Jensens-Device/PHP/jensens-device.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
$i;
|
||||
function sum (&$i, $lo, $hi, $term) {
|
||||
$temp = 0;
|
||||
for ($i = $lo; $i <= $hi; $i++) {
|
||||
$temp += $term();
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
echo sum($i, 1, 100, create_function('', 'global $i; return 1 / $i;')), "\n";
|
||||
//Output: 5.18737751764 (5.1873775176396)
|
||||
|
||||
function sum ($lo,$hi)
|
||||
{
|
||||
$temp = 0;
|
||||
for ($i = $lo; $i <= $hi; $i++)
|
||||
{
|
||||
$temp += (1 / $i);
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
echo sum(1,100);
|
||||
|
||||
//Output: 5.1873775176396
|
||||
Loading…
Add table
Add a link
Reference in a new issue