This C project prints out the first Fibonacci arrangement of N numbers. In arithmetic, the Fibonacci numbers are a succession of numbers named after Leonardo of Pisa, known as Fibonacci. The principal number of the arrangement is 0, the second number is 1, and each ensuing number is equivalent to the aggregate of the past two quantities of the grouping itself, hence making the succession 0, 1, 1, 2, 3, 5, 8, and so forth.

So this system prints the N quantities of Fibonacci arrangement on the screen where N is the whole number enterd by the client.

/*******************************************************

* MYCPLUS Sample Code - http://www.mycplus.com *

*

* This code is made accessible as a support of our *

* guests and is given entirely to the *

* motivation behind representation. *

*

* Please guide all request to saqib at mycplus.com *

*******************************************************/

#include

int main(void) {

int n;/* The quantity of fibonacci numbers we will print */

int i;/* The record of fibonacci number to be printed next */

int current;/* The estimation of the (i)th fibonacci number */

int next;/* The estimation of the (i+1)th fibonacci number */

int twoaway;/* The estimation of the (i+2)th fibonacci number */

printf("How numerous Fibonacci numbers would you like to process? ");

scanf("%d", &n);

in the event that (n<=0)

printf("The number ought to be positive.n");

else {

printf("nntI t Fibonacci(I) nt=====================n");

next = current = 1;

for (i=1; i<=n; i++) {

printf("t%d t %dn", i, current);

twoaway = current+next;

current = next;

next = twoaway;

}

}

}

/* The yield from a keep running of this system was:

What number of Fibonacci numbers would you like to figure? 9

I Fibonacci(I)

=====================

 
Top