Code snippets to perform Fibonacci mathematical functions

Could anyone provide code snippets in c# and vb.Net to perdform the following...

find the sum of the numbers in the Fibonacci sequence under 4 million,
and finding the sum of the multiples of 3 and 5 between 1 and 1000

I would like to get an idea or picture of what code in c# and vb.Net would look like to perform this

The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. Similarly, the 3 is found by adding the two numbers before it (1+2),

Thanks in advance
tesla764Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
This smells like a school assignment.
1
Atdhe NuhiuCommented:
You should do it yourself and if it doesn't work, ask specific questions. Some experts may still not respond if they think it is homework
0
KimputerCommented:
Definitely a school assignment. Therefore I'm only showing you some basics that doesn't totally fit your question, you have to think the rest through yourself:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim Inputnumber As Integer
        Inputnumber = TextBox1.Text

        MsgBox(recursivefunction(Inputnumber, 0, 1, "0,1"))



    End Sub

    Function recursivefunction(inputnumber As Integer, secondlast As Integer, last As Integer, longstring As String)
        Dim tempsecond = secondlast
        secondlast = last
        last = tempsecond + last
        If inputnumber = 0 Then
            recursivefunction = longstring
        Else
            recursivefunction = recursivefunction(inputnumber - 1, secondlast, last, longstring + "," + last.ToString)
        End If

    End Function

End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tesla764Author Commented:
Well your response was at least some what helpful. This is not a school assignment. I am 56 years old and not in school. I simply wanted to see what code would look like to perform the Fibonacci Sequence. I didn't ask to have a project written.   Unbelievable I that I would pay to join Experts Exchange and get the kind of responses I did. If you are not here to help then why do you exist?
0
KimputerCommented:
The second and third very specific lines threw us off I guess (too detailed spec). It's because Experts Exchange doesn't allow experts to help with homework assignments (as stated somewhere in the EULA).
Thanks for the points in any case, and please note I used integer on purpose (so you would run into the ceiling pretty soon, and start using that gray matter as to why the program stopped working).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.