0
Level points C#
Please tell where i am wrong
3 Respuestas
+ 10
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 = (levels + 1) * levels / 2;
return total;
+ 5
if(levels == 1){
return 1;
}
return levels + Points(levels - 1);
}
Thakkar Heer You need to use recursion to constantly minus the level the user is on and return the amount of points he gains.
+ 3
Read Question properly for this problem u need one loop upto base case suppose if u have 5 level then loop should start form 0 to 4 he u have to add points sum=sum+i;
Or u can do this with recursive type function suppose n is a number
return n+(n-1)