Welcome to W3Courses
 Like Us on Facebook

Source Code for the Tribonacci Function in C Programming

Following is the source code for the Tribonacci Function in C Programming

int f (int n)
{  if (n<3)
       return 1;
    if (n>=3)
        return f(n-1) + f(n-2) + f(n-3);
}
main()
{  int n;
    printf ("Enter a number: ");
    scanf ("%d", &n);
    printf ("%d\n", f(n));
}

Share