473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

cprogram for fibonnacci series

can we try writing a simple c program to do fibonnacci series?
Sep 11 '06 #1
3 2543
Suppose the fibonacci sequence is like this.....

1 1 2 3 5 8 13 ...........

So first two terms are 1 and 1. So store these terms in two variables.

let a=1 and b=1

Now next term will be the sum of two previous terms.

c= a+b (=3 for the first time)

In order to calculate the further terms iteratively, you have shift the value of b to a and c to b and then again calculate c.
Sep 11 '06 #2
risby
30
Suppose the fibonacci sequence is like this.....
1 1 2 3 5 8 13 ...........

Or, declare an array of type integer, initialize the first two elements with the value 1 and then, looping from the third element to the final element, store the sum of the previous two elements in the current element.
Sep 12 '06 #3
Use recursion....
Sep 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sriram Krishnan [at] gmx [dot] net | last post by:
Given an arbitrary number series, how do I identify the series and find the Nth number... for e.g 1,3,5,7 is an AP and the next number will be 9 1,8,27,64 is the series of cubes and the next will...
4
by: aW | last post by:
I have an interesting dilemma. I have a table with the following records: =================================================== Box | Series Start | Series End...
1
by: Sriram Krishnan [at] gmx [dot] net | last post by:
Given an arbitrary number series, how do I identify the series and find the Nth number... for e.g 1,3,5,7 is an AP and the next number will be 9 1,8,27,64 is the series of cubes and the next will...
4
by: geoffp | last post by:
I need to generate reproducible random number series. I've done the obvious - use mt_srand with the same seed. This supposedly will create the same series every time. Is this true? Its not...
1
by: sekitoleko | last post by:
c program to generate fibonnacci series
1
by: sekitoleko | last post by:
fibonnacci series are a summation of the preceding two elements to give a proceeding element.Write a program to execute the series up to 10 numbers
4
by: keirnus | last post by:
Hello, I've been coding in Access VBA to create an Excel Graph and it was good. Until I got this error: Please check the code below: Private Sub TestGraph3()
1
by: Scholar | last post by:
Hi,i am working on a c++ project which will find the nth term of a given series.The series would be given in the form of first 4 or 5 terms.I have the basic alogorithm which can find the nth term of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.