Skip to content

Instantly share code, notes, and snippets.

@Brianceasar
Last active November 30, 2022 06:29
Show Gist options
  • Save Brianceasar/4cd9ef8ac993f39c86c71ab2c22c7bd1 to your computer and use it in GitHub Desktop.
Save Brianceasar/4cd9ef8ac993f39c86c71ab2c22c7bd1 to your computer and use it in GitHub Desktop.
Program that prints the first 100 members of the sequence of Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, …
namespace FibonacciSequence
{
class Program
{
static void Main()
{
BigInteger newElement;
BigInteger[] sequenceMembers = { 0, 1 };
Console.Write("{0},\n{1},\n", sequenceMembers[0], sequenceMembers[1]);
for (int i = 0; i < 98; i++)
{
newElement = sequenceMembers[0] + sequenceMembers[1];
Console.WriteLine("{0},",newElement);
sequenceMembers[0] = sequenceMembers[1];
sequenceMembers[1] = newElement;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment