+ 1

I can't figure out how to do a practice please help 😫

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. https://code.sololearn.com/cQ8SHVXQdiC3/?ref=app

22nd Aug 2021, 12:00 AM
dark Apprentice
6 Respuestas
+ 1
dark Apprentice I found 1 too many } & some strange stuff in your code. I adapted it a bit along the lines of your concept, but this is not a recursive approach using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { int levels = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Points(levels)); } static int Points(int levels) { //your code goes here int total = 0; int num = 1; while(num <= levels) { total += num; num++; } return total; } } }
22nd Aug 2021, 3:24 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Syntax error
22nd Aug 2021, 12:16 AM
Gaurav Dixit🇮🇳
Gaurav Dixit🇮🇳 - avatar
+ 1
Thank you
22nd Aug 2021, 3:53 AM
dark Apprentice
0
Where?
22nd Aug 2021, 12:29 AM
dark Apprentice
0
What?
22nd Aug 2021, 1:36 AM
dark Apprentice
- 1
dark Apprentice Any block not close with curly braces
22nd Aug 2021, 12:43 AM
Gaurav Dixit🇮🇳
Gaurav Dixit🇮🇳 - avatar