Click here to Skip to main content
16,016,736 members
Home / Discussions / C#
   

C#

 
GeneralRe: Optimizing Fibonacci Calculation Pin
Max Holder18-Apr-13 3:57
professionalMax Holder18-Apr-13 3:57 
QuestionRe: Optimizing Fibonacci Calculation Pin
Kenneth Haugland18-Apr-13 4:08
mvaKenneth Haugland18-Apr-13 4:08 
AnswerRe: Optimizing Fibonacci Calculation Pin
Max Holder18-Apr-13 4:10
professionalMax Holder18-Apr-13 4:10 
GeneralRe: Optimizing Fibonacci Calculation Pin
Kenneth Haugland18-Apr-13 4:16
mvaKenneth Haugland18-Apr-13 4:16 
GeneralRe: Optimizing Fibonacci Calculation Pin
Richard Deeming18-Apr-13 4:23
mveRichard Deeming18-Apr-13 4:23 
GeneralRe: Optimizing Fibonacci Calculation Pin
Kenneth Haugland18-Apr-13 4:26
mvaKenneth Haugland18-Apr-13 4:26 
GeneralRe: Optimizing Fibonacci Calculation Pin
Richard Deeming18-Apr-13 5:05
mveRichard Deeming18-Apr-13 5:05 
GeneralRe: Optimizing Fibonacci Calculation Pin
Kenneth Haugland18-Apr-13 5:14
mvaKenneth Haugland18-Apr-13 5:14 
None of my implementations work above n=70 regardless of what I do so I went for Numerics.BigInteger:
VB
Private Function GetFib2(ByVal n As Integer) As Numerics.BigInteger
    Dim a As New Numerics.BigInteger
    a = 0
    Dim b As New Numerics.BigInteger
    b = 1

    If (n = 0) Then Return a
    If (n = 1) Then Return b

    For i As UInt64 = 2 To n
        a = a Xor b
        b = b Xor a
        a = a Xor b

        ' add
        b += a
    Next

    Return b
End Function


This is always correct, however it might be a little slower...
GeneralRe: Optimizing Fibonacci Calculation Pin
Max Holder18-Apr-13 5:02
professionalMax Holder18-Apr-13 5:02 
GeneralRe: Optimizing Fibonacci Calculation Pin
Jasmine250118-Apr-13 6:38
Jasmine250118-Apr-13 6:38 
GeneralRe: Optimizing Fibonacci Calculation Pin
harold aptroot18-Apr-13 4:25
harold aptroot18-Apr-13 4:25 
GeneralRe: Optimizing Fibonacci Calculation Pin
Max Holder18-Apr-13 21:20
professionalMax Holder18-Apr-13 21:20 
GeneralRe: Optimizing Fibonacci Calculation Pin
harold aptroot18-Apr-13 21:25
harold aptroot18-Apr-13 21:25 
GeneralRe: Optimizing Fibonacci Calculation Pin
PIEBALDconsult24-Apr-13 4:23
mvePIEBALDconsult24-Apr-13 4:23 
GeneralRe: Optimizing Fibonacci Calculation Pin
PIEBALDconsult20-Apr-13 6:31
mvePIEBALDconsult20-Apr-13 6:31 
GeneralRe: Optimizing Fibonacci Calculation Pin
harold aptroot20-Apr-13 6:41
harold aptroot20-Apr-13 6:41 
GeneralRe: Optimizing Fibonacci Calculation Pin
PIEBALDconsult20-Apr-13 9:36
mvePIEBALDconsult20-Apr-13 9:36 
GeneralRe: Optimizing Fibonacci Calculation Pin
harold aptroot20-Apr-13 9:58
harold aptroot20-Apr-13 9:58 
GeneralRe: Optimizing Fibonacci Calculation Pin
PIEBALDconsult20-Apr-13 10:22
mvePIEBALDconsult20-Apr-13 10:22 
GeneralRe: Optimizing Fibonacci Calculation Pin
Kenneth Haugland18-Apr-13 4:55
mvaKenneth Haugland18-Apr-13 4:55 
GeneralRe: Optimizing Fibonacci Calculation Pin
Richard Deeming18-Apr-13 5:09
mveRichard Deeming18-Apr-13 5:09 
AnswerRe: Optimizing Fibonacci Calculation Pin
Clifford Nelson18-Apr-13 5:15
Clifford Nelson18-Apr-13 5:15 
QuestionRe: Optimizing Fibonacci Calculation Pin
Kenneth Haugland18-Apr-13 6:29
mvaKenneth Haugland18-Apr-13 6:29 
AnswerRe: Optimizing Fibonacci Calculation Pin
harold aptroot18-Apr-13 6:39
harold aptroot18-Apr-13 6:39 
GeneralRe: Optimizing Fibonacci Calculation Pin
harold aptroot18-Apr-13 6:55
harold aptroot18-Apr-13 6:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.