Ahmet Taha

Ahmet Taha

  • 1.7k
  • 380
  • 8.1k

c# console factorial statement problem

Oct 24 2021 3:39 AM

Hello Guyz I need your help,

The out put should be like ths:

Enter Number of Range : 3
1
2 3
4 5 6
The factorial Factor is :       720

and here is my code:

int x; int y; int k = 1; int sum=1;
Console.Write("Enter Number of Range :\t");
int num = int.Parse(Console.ReadLine());
for (x = 1; x <= num; x++)
{
    for (y = 1; y <= x; y++)
        Console.Write("{0}", k++ + " ");
    Console.Write("\n");
    //sum += k++;
}
Console.Write("The factorial Factor is :\t");
////for (x = 1; x <= num; x++)
for (y = 1; y <= x; y++)
{
    sum += y++;
    Console.Write("{0}", sum);
}


//===============
Console.ReadKey();

 


Answers (4)