Created
September 6, 2015 10:22
-
-
Save angelovstanton/b4e62706f2dc05f3c391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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