Fibonacci numbers in Pike
Example for versions
Pike 7.8
This example uses recursive definition of Fibonacci numbers.
int fibonacci(int n)
{
return ( n<=2 ? 1 : fibonacci(n-1) + fibonacci(n-2) );
}
void main()
{
for (int n=1; n<=16; n++)
write(fibonacci(n)+", ");
write("...\n");
}
Comments
]]>blog comments powered by Disqus
]]>