fibonacci series using recursion
C
//Fibonacci Series using Recursion
#include<bits/stdc++.h>
using namespace std;
int fib(int n)
{
if (n <= 1)
return n;
return fib(n-1) + fib(n-2);
}
int main ()
{
int n = 9;
cout << fib(n);
getchar();
return 0;
}
// This code is contributed
// by Akanksha Rai
//Fibonacci Series using Recursion
class fibonacci
{
static int fib(int n)
{
if (n <= 1)
return n;
return fib(n-1) + fib(n-2);
}
public static void main (String args[])
{
int n = 9;
System.out.println(fib(n));
}
}
/* This code is contributed by Rajat Mishra */
// C# program for Fibonacci Series
// using Recursion
using System;
public class GFG
{
public static int Fib(int n)
{
if (n <= 1)
{
return n;
}
else
{
return Fib(n - 1) + Fib(n - 2);
}
}
// driver code
public static void Main(string[] args)
{
int n = 9;
Console.Write(Fib(n));
}
}
// This code is contributed by Sam007
# Function for nth Fibonacci number
def Fibonacci(n):
if n<0:
print("Incorrect input")
# First Fibonacci number is 0
elif n==0:
return 0
# Second Fibonacci number is 1
elif n==1:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2)
# Driver Program
print(Fibonacci(9))
#This code is contributed by Saket Modi
//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;
}
Also in C:
- Title
- How to pull images from Docker Registry
- Category
- C
- Title
- objective c swizzle method
- Category
- C
- Title
- function pointer c
- Category
- C
- Title
- confirm sweet alert
- Category
- C
- Title
- Fibonacci program c pthread
- Category
- C
- Title
- set timezone in debian terminal
- Category
- C
- Title
- how to write function in c
- Category
- C
- Title
- read a document in c getting name from console
- Category
- C
- Title
- \0 in c
- Category
- C
- Title
- Declare macro
- Category
- C
- Title
- entity framework core discard changes
- Category
- C
- Title
- read from stdin c
- Category
- C
- Title
- c substring
- Category
- C
- Title
- reset c array to zero
- Category
- C
- Title
- #include<stdlib.h>
- Category
- C
- Title
- how to free a 2d array correctly
- Category
- C
- Title
- uninstall elgg from hostgtor
- Category
- C
- Title
- wait function in c
- Category
- C
- Title
- c producer consumer pthread semaphore
- Category
- C
- Title
- c vs python
- Category
- C
- Title
- how to ascii art in c
- Category
- C
- Title
- .\main.c:4:8: error: expected declaration specifiers or '...' before '\x6f726c64'
- Category
- C
- Title
- tar cmd
- Category
- C
- Title
- fa fa-facebook
- Category
- C
- Title
- c check if char is an operator
- Category
- C
- Title
- how to print the address of a pointer in c
- Category
- C
- Title
- keras conv2d batchnorm
- Category
- C
- Title
- pass the pointer in C
- Category
- C
- Title
- c print array
- Category
- C
- Title
- c bit access union
- Category
- C
- Title
- entete
- Category
- C
- Title
- what is the meaningof noremap
- Category
- C
- Title
- factors using recursion
- Category
- C
- Title
- text wrap terminal colour
- Category
- C
- Title
- change plot line color in matplotlib
- Category
- C
- Title
- can we write a program without main in c
- Category
- C
- Title
- change no_turbo
- Category
- C
- Title
- CL/cl.h: No such file or directory
- Category
- C
- Title
- add border to image android
- Category
- C
- Title
- hello world
- Category
- C
- Title
- c concatenate strings
- Category
- C
- Title
- c value set to zero __memmove_avx_unaligned_erms
- Category
- C
- Title
- how to put quotes inside string c
- Category
- C
- Title
- arduino digital read
- Category
- C
- Title
- vbnet create and write on file
- Category
- C
- Title
- c defined value sum
- Category
- C
- Title
- C largest unsigned int
- Category
- C
- Title
- ModuleNotFoundError: No module named 'easydict'
- Category
- C
- Title
- read files in c
- Category
- C
- Title
- arduino define
- Category
- C
- Title
- 'int' is not a subtype of type 'double' dart
- Category
- C
- Title
- how to find the ith row of pascal's triangle in c
- Category
- C
- Title
- vbl share price
- Category
- C
- Title
- time now c
- Category
- C
- Title
- classification report to excel
- Category
- C
- Title
- primo
- Category
- C
- Title
- slug urls django
- Category
- C
- Title
- how to check the size of a file in linux c
- Category
- C
- Title
- double return type in c
- Category
- C
- Title
- c if int
- Category
- C
- Title
- atoi
- Category
- C
- Title
- error: ‘cout’ was not declared in this scope
- Category
- C
- Title
- es par
- Category
- C
- Title
- atoi c
- Category
- C
- Title
- california
- Category
- C
- Title
- how to make a linked list in c
- Category
- C
- Title
- code in c skipping over scanf
- Category
- C
- Title
- how to login to another user in powershell
- Category
- C
- Title
- code wars responsable drinker
- Category
- C
- Title
- get regedit value cmd
- Category
- C
- Title
- declaring a volatile in c
- Category
- C
- Title
- mostrar lista recursiva
- Category
- C
- Title
- turn a char array into double C
- Category
- C
- Title
- v
- Category
- C
- Title
- boolean function c
- Category
- C
- Title
- printf("%3d ",XX);
- Category
- C
- Title
- c matrix sintax
- Category
- C
- Title
- printf n characters c
- Category
- C
- Title
- hopw to check how many duplicates in an array c
- Category
- C
- Title
- docker logs follow
- Category
- C
- Title
- c bit access struct
- Category
- C
- Title
- convert string to float c
- Category
- C
- Title
- write a binary file c
- Category
- C
- Title
- incompatible types when initializing type ‘float’ using type ‘point {aka struct point}’
- Category
- C
- Title
- how to use a pointer as a parameter in c
- Category
- C
- Title
- sustituir un dígito por otro
- Category
- C
- Title
- java.lang.SecurityException: Permission denied (missing INTERNET permission?)
- Category
- C
- Title
- print in c
- Category
- C
- Title
- matrix c declaration
- Category
- C
- Title
- entete c/c++
- Category
- C
- Title
- scanf read line
- Category
- C
- Title
- how to download file in powershell
- Category
- C
- Title
- division recursiva
- Category
- C
- Title
- scanf integer
- Category
- C
- Title
- c struct
- Category
- C
- Title
- array length c
- Category
- C
- Title
- arduino digital input pins
- Category
- C
- Title
- check if string in string c
- Category
- C
- Title
- potencia recursiva
- Category
- C
- Title
- how to remove \n from a string c
- Category
- C