<?php
//Enter your code here, enjoy!
// fib Numbers : 1, 1 ,2, 3, 5, 8, 13
function fib($n){
if($n >= 3){
return fib($n-2) + fib($n-1);
} else{
return 1;
}
}
$fib = fib(5);
echo $fib;
<?php
function fact($n){
if($n >= 1){
return $n * fact($n-1);
} else{
return 1;
}
}
$fact = fact(5);
echo $fact;
<?php
// 10 -> 5 -> 16
class Node{
public $value;
function _constructor($value){
$this->value = $value;
$this->next = null;
}
}
$node = new Node(10);
var_export($node);
class LinkedList{
public $head;
function _constructor($value){
$this->head = (object)[
value => $value
];
}
}
$linkedList = new LinkedList(10);