Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,33 @@
<?php
class CatalanNumbersSerie
{
private static $cache = array(0 => 1);
private function fill_cache($i)
{
$accum = 0;
$n = $i-1;
for($k = 0; $k <= $n; $k++)
{
$accum += $this->item($k)*$this->item($n-$k);
}
self::$cache[$i] = $accum;
}
function item($i)
{
if (!isset(self::$cache[$i]))
{
$this->fill_cache($i);
}
return self::$cache[$i];
}
}
$cn = new CatalanNumbersSerie();
for($i = 0; $i <= 15;$i++)
{
$r = $cn->item($i);
echo "$i = $r\r\n";
}
?>

View file

@ -0,0 +1,13 @@
<?php
$n = 15;
$t[1] = 1;
foreach (range(1, $n+1) as $i) {
foreach (range($i, 1-1) as $j) {
$t[$j] += $t[$j - 1];
}
$t[$i +1] = $t[$i];
foreach (range($i+1, 1-1) as $j) {
$t[$j] += $t[$j -1];
}
print ($t[$i+1]-$t[$i])."\t";
}