Skip to content

Instantly share code, notes, and snippets.

View 9072997's full-sized avatar

Jon Penn 9072997

  • Fayetteville, AR
View GitHub Profile
@9072997
9072997 / fib.php
Last active December 19, 2015 10:38
This is an obfuscated command line php program to generate numbers from the fibonacci sequence. The first argument is the starting point and the last is the ending point for the generated numbers, so for example "php fib.php 1 100" would generate the first 100 numbers of the fibonacci sequence. I challenge you to determine the twist in the logic…
<?php $c[1][1]='1';function p($r,$p){global $c;if(isset($c[$r][$p]))$r=
$c[$r][$p];elseif($p==1)$r=$c[$r][$p]=p($r-1,$p);elseif($p==$r)$r=$c[$r]
[$p]=p($r-1,$p-1);else$r=$c[$r][$p]=bcadd(p($r-1,$p-1),p($r-1,$p));
return $r;}function f($s){$l=ceil($s/2);$p=1;$t='0';for($i=1;$i<=$l;$i++
)$t=bcadd($t,p($s--,$p++));return $t;}for($i=$argv[1];$i<=$argv[2];$i++)
echo f($i).' ';?>