answersLogoWhite

0

Algorithm of Fibonacci series in c?

Updated: 8/11/2023
User Avatar

Wiki User

11y ago

Best Answer

#include<stdio.h>

#include<conio.h>

int fib(int a);

main()

{

int a;

clrscr();

scanf("%d",&a);

for(int i=0;i<a;i++)

printf("%d\n",fib(i));

}

int fib(int a)

{

if(a==0)

return 0;

if(a==1)

return 1;

else

return (fib(a-1)+fib(a-2));

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

In algorithm:

1. Assign sum=0, A=0, B=1, i=1

2. Get the no. of terms upto which u want to generate the Fibonacci no, i.e., n.

3.Add A and B to get the next Fibonacci number

4. Assign the value of B to A i.e. A=B

5. Assign the value of sum to B i.e. B=sum

6. Write the value of su to get next Fibonacci number in the series.

7. increment i with 1 i.e. i=i+1 and repeat step 3,4,5,6 with the last value of i=n(n is the no. of terms which u wnt to generate Fibonacci no. series.)

8. Stop

Read more: Algorithm_to_write_a_Fibonacci_series

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Algorithm of Fibonacci series in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is Fibonacci heaps algorithm?

fibonacci heap is a heap


How do you calculate the nth term in the Fibonacci sequence using C?

what? Assuming you wanted an algorithm to find the nth number in the Fibonacci sequence: double Fib(int i) { double x = 1; double y = 1; if (i


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


Examples of algorithms?

bisection algorithm (see link)Euclid's algorithm (see link)Fibonacci search (see link)


Write a program using while loop that generates Fabonaci series up to 200?

//to generate Fibonacci series upto a range of 200....(in C).... #include&lt;stdio.h&gt; main() { int a,b,c,i; a=0; b=1; printf("\n FIBONACCI SERIES .....\t"); i=1; while(i&lt;=(200-2)) { c=a+b; printf("\t%d",c); a=b; b=c; i++; } }


Is 20 a Fibonacci number?

20 is not a term in the Fibonacci series.


C orogram for Fibonacci series?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { printf("The first 20numbers of Fibonacci series are:"); int a=0, b=1, c, n=2; printf("%d \t, %d", &amp;a, &amp;b); while(n&lt;20) { c=a+b; printf("\t %d", &amp;c); a=b; b=c; n++; } getch(); }


Program to generate Fibonacci series using storage class in c plus plus?

i dn't know. haha


Fibonacci series program in vb.net?

This is not a homework board. I will give you a rough algorithm in C#int firstnum= 1;int finalnum = 1;int nextNumber;System.Console.Write(finalnum + " ");while (finalnum < 50){System.Console.Write(finalnum + " ");nextNumber = finalnum + firstnum;firstnum= finalnum ;finalnum = nextNumber;}


Who invent sEquence and series?

Fibonacci!


What is golden ratio in Fibonacci series?

As you expand the Fibonacci series, each new value in proportion to the previous approaches the Golden Ratio.


Can you have the program in C plus plus for recursive function generating a series of terms?

Yes, this can be done. For example for Fibonacci series. You will find plenty of examples if you google for the types of series you need to be generated.