0
Level Points C# ( Please Solve this problem)
Level Points C# Passing the first level of a video game awards the player 1 point. For each subsequent level passed, the points awarded increment by 1 (2 for the 2nd level, 3 for the 3rd, and so on). The program you are given takes the number of passed 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. Sample Input 3 Sample Output 6 Explanation Level 1: 1 point Level 2: 2 points Level 3: 3 points Total: 1+2+3 = 6 points.
5 Respuestas
+ 2
Write down this Code after The Comment
// write your code here
if(levels == 1){
return 1;
}
return levels + Points(levels-1);
And Run it
0
Why did you tag all those languages when it is a C# task? 👉ONLY TAG THE RELEVANT PROGRAMMING LANGUAGE
Read the task description carefully – it gives you the hints how to solve it. 👉Please show your code attempt if you need help!
0
Lisa I'm confused that's why I asked. Should I use recursion method or? Waiting for the right answer.
0
If you read the task description, you'll notice that you are supposed to calculate ***recursively***
- 1
// try this method and then run it
int tot = 0;
for(int a=levels; a>=1; a--)
{
tot = tot + a;
}
return tot;