Question: 1 2 . The triangular numbers are as follows: 1 = 1 3 = 1 + 2 6 = 1 + 2 + 3 1

12. The triangular numbers are as follows:
1=1
3=1+2
6=1+2+3
10=1+2+3+4
15=1+2+3+4+5
21=1+2+3+4+5+6
etc.
The series begins with 1(the first triangular number). To calculate the nth triangular
number, n is added to the previous triangular number. For example, the fourth triangular
number is calculated by adding 4 to the third triangular number (which is 6), i.e.10=(1
+2+3)+4.
Write a recursive function (pseudocode) in that will calculate the nth triangular number.
Note: will not receive any credit for a non-recursive solution.
For example, the following statements would lead to the underlined output:
Example 1:
print ( triNum(1));
1
Example 2:
print ( triNum(2));
3
Example 3:
print ( triNum(5));
15
Note: you may assume the parameter will be positive no error checking of inputs is
required

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!