Describe what this function does. Try different numbers as input.

```
def test(num):
if num > 0:
return test(num-1) + num
else:
return 0
```


This method recursively calls itself with a decremented number, but adds that decremented number to the returned value till it hits 0. This causes it to return 3 for 2, 6 for 3, 10 for 4, and so on.

Computer Science & Information Technology

You might also like to view...

When Hyper-V loads for the first time, it creates the parent _______________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Using what utility allows you to build your own customized console windows?

A. Microsoft Management Console B. Microsoft Manager Console C. Microsoft Management Components D. Microsoft Manager Controls

Computer Science & Information Technology

The Delete query is often used immediately after a(n) ________ query

Fill in the blank(s) with correct word

Computer Science & Information Technology

for (int outer = 0; outer < 2; outer++){      for (int inner = 0; inner < 3; inner++)     {Console.WriteLine("Outer: {0}\tInner: {1}", outer, inner);      }} How many lines will be printed for the above nested loop?

A. 2 B. 3 C. 5 D. 6

Computer Science & Information Technology