Basic Fractal Numbers

The following is code that I created to create my fractal nubmers, sharing it with the community if it will help. I can get it to go up to 91 iterations with out breaking because of the 64 bit limitation. I’m sure there is another way to get above 91 iterations and if you do I would encourage you to respond to this post if you feel inclined to do so.

internal class Program
    {
        static private long firstNumber, secondNumber, result;
        static void Main(string[] args)
        {
            firstNumber = 0;
            secondNumber = 1;
            result = 0;

            for (int i = 0; i < 100; i++)
            {
                result = firstNumber + secondNumber;
                Console.WriteLine("Level " + i + " is " + result);
                secondNumber = firstNumber;
                firstNumber = result;
            }
            Console.ReadLine();
        }
}
1 Like

This is a variant of the Fibonacci sequence. Except it’s slightly different because you set the secondNumber = firstNumber instead of secondNumber = result, which just delays the sequence by 1 (the first iteration swaps firstNumber and secondNumber.

…yeah…

2 Likes

I took it for granted that it worked after line 20, good catch.

1 Like

It is if you are using it for GameDevelopment, like a leveling system