//Fibonacci Series using Recursion
#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;
}
#include <stdio.h>
// declaring function
int fib(int num)
{
if (num == 0)
{
return 0;
}
else if (num == 1)
{
return 1;
}
else
{
return fib(num - 1) + fib(num - 2);
}
}
int main()
{
int a;
printf("enter the number of terms you want to print
");
scanf("%d", &a);
printf("fibonacci series upto %d is : ", a);
for (int c = 0; c <a; c++)
{
printf(" %d ", fib(c));
}
return 0;
}
// Sum of fibonacci series
#include <stdio.h>
int main()
{
int fib[1000];
int num, sum = 1, i;
scanf(" %d", &num);
fib[0] = 0;
fib[1] = 1;
printf(" %d + %d", fib[0], fib[1]);
for(i = 2; i < num; i++){
fib[i] = fib[i-1] + fib[i-2];
printf(" + %d", fib[i]);
sum += fib[i];
}
printf("
= %d", sum);
return 0;
}
Code Example |
---|
C :: input multipal data types |
C :: BSTNode root |
C :: georgia institute of technology |
C :: unigine |
C :: compil cywin cgi |
C :: fraction sum c |
C :: c limit value range |
C :: brew autoremove |
C :: denomination counter |
C :: C static libraries creation |
C :: variadic macros in c |
C :: cum creez un nou nod how to create a new node |
C :: deepak rake |
C :: fgets langage c |
C :: profile time bash script |
C :: C programming statician |
C :: is 0 true or false |
C :: c logarithm check if number is base |
C :: create a buffer in c |
C :: printf("%d", 10 ? 0 ? 5:1:1:12) what will print |
C :: C Macros using #define |
Dart :: flutter debug tag |
Dart :: python change type of elements in list |
Dart :: rupee icon in flutter |
Dart :: loop in dart |
Dart :: how to hide notficition bar in flutter |
Dart :: File dart get file extension |
Dart :: flutter floatingactionbutton position |
Dart :: dart list map index |
Dart :: DartPad requires localStorage to be enabled |