Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Can you write an algorithm to find fibonacci series?

user-image
Question ajoutée par feysel debela
Date de publication: 2016/12/05
Riki  Mondal
par Riki Mondal , Full Stack Debeloper , National Institute of Technology Durgapur

#include<stdio.h> int fib(int n) {    if (n <= 1)       return n;    return fib(n-1) + fib(n-2); }   int main () {   int n = 9;   printf("%d", fib(n));   getchar();   return 0; }

Pradeep  Sharma
par Pradeep Sharma , Assistant Professor , Assam down town Unniversity

Fibonacci(n)

begin:

declare f0, f1

set f0=0  and f1=1

display f0, f1

for 1: n

fib = f0 + f1

f0 = f1

f1 = fib

display fib

end

/* Fibonacci Series c language */ #include<stdio.h>   int main() { int n, first = 0, second = 1, next, c;   printf("Enter the number of terms\\n"); scanf("%d",&n);   printf("First %d terms of Fibonacci series are :-\\n",n);   for ( c = 0 ; c < n ; c++ ) { if ( c <= 1 ) next = c; else { next = first + second; first = second; second = next; } printf("%d\\n",next); }   return 0; }

 

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?