[Challenge] Fibonacci Sequence
2013-08-09, 12:43 PM,
#1
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.

Reply
2013-08-28, 03:59 PM,
#2
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()
            lstFib.Items.Add(intNumber)
        Loop Until intLoop = 10

    End Sub

    Sub calculate()
        intNumber = intFirstPrev + intSecPrev
        intSecPrev = intFirstPrev
        intFirstPrev = intNumber
    End Sub
End Class
Reply





About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top