If you are browsing this forum, it is a safe assumption to believe you know of the Fibonacci Series.

After having a couple of minutes, and some random thoughts, I put together a little piece of code that will print this series out to a file.

Private Sub FibWrite(ByVal iMax As Int64)
    Dim sw As New StreamWriter("Path")
    Dim n0 As Int64 = 0
    Dim n1 As Int64 = 1

    Try
        For i = 0 To iMax
            Dim iTemp As Int64 = n1
            n1 = n1 + n0
            n0 = iTemp
            sw.WriteLine(n1)
        Next
    Catch ex As Exception
        MsgBox(ex.ToString)
        sw.WriteLine(ex.Message)
    Finally
        sw.Close()
        sw.Dispose()
    End Try
End Sub

I reached a total of 90 iterations before overflow occurs.

Let's have some fun with this, shall we?

If you use BigInteger as in

Private Sub FibWrite()

    Dim sw As New System.IO.StreamWriter("d:\temp\fib.txt")

    Dim n0 As BigInteger = 0
    Dim n1 As BigInteger = 1

    Try
        For i = 1 To 1000
            Dim iTemp As BigInteger = n1
            n1 = n1 + n0
            n0 = iTemp
            sw.WriteLine(n1)
        Next
    Catch ex As Exception
        Debug.WriteLine(ex.Message)
        sw.Close()
    End Try

    sw.Close()

End Sub

The 1000th number in the sequence is

70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501

And the 10000th number is

54438373113565281338734260993750380135389184554695967026247715841208582865622349017083051547938960541173822675978026317384359584751116241439174702642959169925586334117906063048089793531476108466259072759367899150677960088306597966641965824937721800381441158841042480997984696487375337180028163763317781927941101369262750979509800713596718023814710669912644214775254478587674568963808002962265133111359929762726679441400101575800043510777465935805362502461707918059226414679005690752321895868142367849593880756423483754386342639635970733756260098962462668746112041739819404875062443709868654315626847186195620146126642232711815040367018825205314845875817193533529827837800351902529239517836689467661917953884712441028463935449484614450778762529520961887597272889220768537396475869543159172434537193611263743926337313005896167248051737986306368115003088396749587102619524631352447499505204198305187168321623283859794627245919771454628218399695789223798912199431775469705216131081096559950638297261253848242007897109054754028438149611930465061866170122983288964352733750792786069444761853525144421077928045979904561298129423809156055033032338919609162236698759922782923191896688017718575555520994653320128446502371153715141749290913104897203455577507196645425232862022019506091483585223882711016708433051169942115775151255510251655931888164048344129557038825477521111577395780115868397072602565614824956460538700280331311861485399805397031555727529693399586079850381581446276433858828529535803424850845426446471681531001533180479567436396815653326152509571127480411928196022148849148284389124178520174507305538928717857923509417743383331506898239354421988805429332440371194867215543576548565499134519271098919802665184564927827827212957649240235507595558205647569365394873317659000206373126570643509709482649710038733517477713403319028105575667931789470024118803094604034362953471997461392274791549730356412633074230824051999996101549784667340458326852960388301120765629245998136251652347093963049734046445106365304163630823669242257761468288461791843224793434406079917883360676846711185597501
commented: Very nice :D +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.