Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created September 6, 2015 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/b4e62706f2dc05f3c391 to your computer and use it in GitHub Desktop.
Save angelovstanton/b4e62706f2dc05f3c391 to your computer and use it in GitHub Desktop.
static unsafe void Fibonacci()
{
const int arraySize = 20;
int* fib = stackalloc int[arraySize];
int* p = fib;
*p++ = *p++ = 1;
for (int i = 2; i < arraySize; ++i, ++p)
{
*p = p[-1] + p[-2];
}
for (int i = 0; i < arraySize; ++i)
{
Console.WriteLine(fib[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment