Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If there are n people that have telephones, and only two people can talk to each

ID: 666250 • Letter: I

Question

If there are n people that have telephones, and only two people can talk to each other at any given times, there can be many different ways in which people can be talking to each other. The number of ways possible grows quickly as the number of people, n, grows. This forms a sequence where the nth term is the number of ways the n people can connect. The first two terms of this sequence are both 1, and then the nth term can be obtained by taking the (n-1)st term and adding it to be the result of n-1 multiplied by the (n-2)nd term. The first few telephone numbers (starting with n=0, i.e,. zero phones) are: 1, 1, 2, 4, 10, 26, 76, 232, 764, 2620, 9496, . . .

Create a recursive function is pseudocode which takes as input an integer n, and return the nth term of the sequence.

Explanation / Answer

PSEUDOCODE:

sequence(int n)
BEGIN:
if(n=0 || n=1) //base case for recursion
return 1;
else
return sequence(n-1)+sequence(n-1)*sequence(n-2) ; //recursively calculte nth term
  
END