How to add commas to factorial loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnkelly11
    New Member
    • Oct 2011
    • 8

    How to add commas to factorial loop

    hi

    could someone help me to format this factorial with commas, to final answer in this factorial loop?

    Code:
    private void btnCalculate_Click(object sender, EventArgs e)
            {
                {
                    decimal number = Convert.ToDecimal(txtNumber.Text);
                    decimal factotorial = 1;
    
    
                    for (int i = 1; i <= number; i++)
                    {
                        factotorial *= i;
    
                    }
    
                    txtFactorial.Text = factotorial.ToString();
    
    
                }
    
            }
    thanks
    Last edited by Banfa; Oct 19 '11, 12:09 PM. Reason: Added [code]...[/code] tags round the code
  • johnkelly11
    New Member
    • Oct 2011
    • 8

    #2
    nevermind i got the answer,change

    txtFactorial.Te xt = factotorial.ToS tring();

    to


    txtFactorial.Te xt = factotorial.ToS tring("n0");

    Comment

    Working...