Question 2 Not complete Marked out of 2.00 Flag question The series of pentagonal numbers can be defined recursively as
Posted: Tue May 24, 2022 8:30 am
code:
int pentagonal_numbers(int n){
}
Question 2 Not complete Marked out of 2.00 Flag question The series of pentagonal numbers can be defined recursively as follows: if n=1 Pn = if n = 2 Pn-1-Pn-2+3 otherwise Complete the definition of the pentagonal_numbers() function which takes a single integer parameter n and returns the nth pentagonal number (an integer). You can assume that n will be 1 or more. The pentagonal_numbers () function must be defined recursively. Some examples of the function being called are shown below. For example: Test Result int n = 1; pentagonal_numbers (1) = 1 printf("pentagonal_numbers (%d) = %d\n", n, pentagonal_numbers(n)); int n = 2; pentagonal_numbers (2) = 5 printf("pentagonal_numbers (%d) = %d\n", n, pentagonal_numbers (n)); int n = 3; pentagonal_numbers (3) = 12 printf("pentagonal_numbers (%d) = %d\n", n, pentagonal_numbers (n)); Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Reset answer 1vint pentagonal_numbers (int n){ 2 3}