QUESTION 1: Consider the task: “print n asterisks” where n is not negative. Which of the following is a valid recursive definition of this task? A) Keep printing asterisks until n of them have been printed. B) If n is greater than zero then print an asterisk and then “print n-1 asterisks”. C) Print an asterisk D) none of the above

QUESTION 1:  Consider the task: “print n asterisks” where n is not negative. Which of the following is a valid recursive definition of this task?  A) Keep printing asterisks until n of them have been printed. B) If n is greater than zero then print an asterisk and then “print n-1 asterisks”. C) Print an asterisk D) none of the above

LANGUAGE: JAVA

CHALLENGE:

QUESTION 1:

Consider the task: “print n asterisks” where n is not negative. Which of the following is a valid recursive definition of this task?

A) Keep printing asterisks until n of them have been printed.
B) If n is greater than zero then print an asterisk and then “print n-1 asterisks”.
C) Print an asterisk
D) none of the above

SOLUTION:

If n is greater than zero then print an asterisk and then “print n-1 asterisks”.

Add comment