0

C# Level Points

The problem is "level points": levels as input. Complete the given function to take that number as an argument, and recursively calculate and return the total number of points given for all passed levels. The procedure was different. How was i supposed to use recursion? I did it like this: Main { int levels = Convert.ToInt32(Console.RL()); Console.WL(Points(levels));} static int Points(int levels, int points = 0){ for(int x = 0; x <=levels; x++){points += x;} return points;}

4th Jan 2023, 3:06 PM
Giovanni Paolo Balestriere
Giovanni Paolo Balestriere - avatar
1 ответ
0
Hello, So doing it recursively, you must call the subroutine itself, define the base case which is where 'levels' will be equal to 1 else we: return levels + Points (levels-1) Hope that helps
4th Jan 2023, 3:59 PM
Hassanah
Hassanah - avatar