Skip to content

Instantly share code, notes, and snippets.

@uyab
Created March 17, 2017 07:15
Show Gist options
  • Save uyab/3bbc2f674d73d1cc139513f4845c081d to your computer and use it in GitHub Desktop.
Save uyab/3bbc2f674d73d1cc139513f4845c081d to your computer and use it in GitHub Desktop.
Deret Fibonacci
<?php
// 0,1,1,2,3,5,8,13
$fib = [];
foreach (range(0, 100) as $i) {
if ($i == 0) {
$fib[$i] = 0;
} elseif ($i == 1) {
$fib[$i] = 1;
} else {
$fib[$i] = $fib[$i - 2] + $fib[$i - 1];
}
}
echo implode('<br>', $fib);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment