Write a recursive function that calculates the N-th term \(U_N\) of the FIBONACCI sequence that is given by the recurrence relation:
\(U_1=1 \ \ \  U_2=1 \ \ \  U_N=U_{N-1}+ U_{N-2}\) (for N>2)


Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>

int fibo(int n)
{
  	if (n == 0 || n == 1)
   		return 1;
   	return fibo(n-1) + fibo(n-2);
}


void main()
{
  	int n;

  	printf("n : ");
  	scanf("%d", &n);


  	printf("fibo(%d)=%d\n",n,fibo(n));

	getch();
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Number pattern 6