Question: Using c++ language, visual studio Display screenshot of output and .cpp Objective: 1. 2. Understand the recurrence relation of sequences Know how to use the
Objective: 1. 2. Understand the recurrence relation of sequences Know how to use the recurrence relation to calculate the n-th term of the sequence, where n is input by users. Given the following recurrence relations of two sequences, write a function for each sequence. The function should return the n-th term of the sequence, where n is input by users. Print out the value in the console. 1. an-2 an-1 + 3 an-2 ; ao =-2, a1 = 3. 2. an= 2an-1-n; a 1: 2 Hint: 1. A single for loop in the function will suffice. 2. Function template is int YourFuntionName(int n) 1. Initialize the starting values (i.e. ao or/and a) 2. If n= 0 or 1, return ao or al 3, if n != 0 or 1, Write a for loop, retrun an
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
