<?php

header('Content-Type: text/plain;');

$start = microtime(true);

function fastfib($n)
{
	$fibs = array();
	
	array_push($fibs, 0);
	array_push($fibs, 1);
	
	for ( $i = 0; $i < $n; ++$i )
	{
		array_push($fibs, $fibs[0] + $fibs[1]);
		array_shift($fibs);
	}
	return $fibs[0];
}

if ( (int)$_GET['n'] > 1000 )
{
	print 'Maximum number of iterations is 1000, sorry! Calculating to that...' . "\n\n";
	$_GET['n'] = 1000;
}

for ( $j = 0; $j < $_GET['n']; ++$j )
{
	print fastfib($j) . "\n";
}

$end = microtime(true);

echo "\n\nTime taken: " . ($end - $start) . ' seconds.';

?>
