We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>//Complete the following function.intfind_nth_term(intn,inta,intb,intc){//Write your code here.if(n==1)returna;if(n==2)returnb;if(n==3)returnc;returnfind_nth_term(n-1,a,b,c)+find_nth_term(n-2,a,b,c)+find_nth_term(n-3,a,b,c);}intmain(){intn,a,b,c;scanf("%d %d %d %d",&n,&a,&b,&c);intans=find_nth_term(n,a,b,c);printf("%d",ans);return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Calculate the Nth term
You are viewing a single comment's thread. Return to all comments →