I have a homework, I should make a program that writes out '*' marks, one in the first line, two in the second line, and so on. The twist is, it must be made with a recursive method, and I can't really handle that.
static void csillag(int i,int x = 1)
{
for (int z = 0; z < x; z++) Console.Write('*');
x++;
while (i > x)
{
Console.WriteLine();
csillag(i);
}
}
This is the code I came up with, but it's not working for some reason, it keeps writing single * one in each line infinitely. I thought, maybe the "int x = 1" part keeps resetting x to 1 each time the method runs itself. Hope you can help, sorry for my unprofessional english.