# [Challenge] Fibonacci Sequence

### Welcome to CPAElites - the original incentive CPA affiliate marketing forum online, solely based on "Cost Per Action".

#### Oloty

##### Well-known member
Heyy y'all,

I'm going to provide you with a snippet that solves for the Fibonacci sequence using two variables.
Write me a proof that explains why this works.
Alternatively, write your own piece of code using two variables.

Code:
``````static int[] Fib(int length)
{
int x = 0;
int y = 1;
int[] fib = new int[length];
for (int i = 0; i < length; i++)
{
fib[i] = y += x;
i++;
fib[i] = x += y;
}
return fib;
}``````

#### Jonte

##### Well-known member
Here's a simple Fibonacci sequence that I wrote in my class yesterday. It uses 4 variables but meh. Here it is anyways in good old VB.NET xD:

Code:
``````Public Class Form1
Dim intNumber As Integer = 1
Dim intFirstPrev As Integer = 1
Dim intSecPrev As Integer = 0
Dim intLoop As Integer

Private Sub btnComp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComp.Click
Do
intLoop = intLoop + 1
calculate()