Functions and Recursions – Arithmetic – Problem #14
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Difficulty: medium
Problem Statement
Define a sequence Gn as: Gn = 0 if n = 0, = 1 if n = 1, = 2 if n = 2, = Gn-1 + Gn-2 + Gn-3 if n >= 3. Write a recursive function for the computation of Gn for a given n. From the main function read an integer n, (<10) and then print Gn.