473,473 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to add commas to factorial loop

8 New Member
hi

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

Expand|Select|Wrap|Line Numbers
  1. private void btnCalculate_Click(object sender, EventArgs e)
  2.         {
  3.             {
  4.                 decimal number = Convert.ToDecimal(txtNumber.Text);
  5.                 decimal factotorial = 1;
  6.  
  7.  
  8.                 for (int i = 1; i <= number; i++)
  9.                 {
  10.                     factotorial *= i;
  11.  
  12.                 }
  13.  
  14.                 txtFactorial.Text = factotorial.ToString();
  15.  
  16.  
  17.             }
  18.  
  19.         }
  20.  
thanks
Oct 18 '11 #1
1 1876
johnkelly11
8 New Member
nevermind i got the answer,change

txtFactorial.Text = factotorial.ToString();

to


txtFactorial.Text = factotorial.ToString("n0");
Oct 18 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Richard Cavell | last post by:
I have a recursive function like this: void MyFunction(int i) { i++; // do something with i if (we're not finished) MyFunction(i); } I keep count of how far nested we are with i. Now, it...
33
by: patrick_woflian | last post by:
hey guys, im just writing a basic calculation at the moment, before building on it for an A-Level piece of work. i can add/divide etc... two numbers together yet i am having a major problem with...
35
by: aNt17017 | last post by:
This is my code: long fact(int n) { if (n == 0) return(1); if(n > 100) { printf("\t\tERROR: %d is too large for factorial.\n", n); return 1;
8
by: salman | last post by:
this program is giving compile time error. so plse ge me the logic of factorial # include <iostream.h> # include <math.h> void main() { int f,sum=0,i,j,n; cout<<"\nEnter Number: ";
5
by: hprYeV | last post by:
I have done a reasonable amount of programming in C++, but the other day I was talking to someone after a lecture in a course on Java who said that they had not been used to the syntax of the Java...
59
by: Umesh | last post by:
i wrote the following program to calculate factorial: #include<stdio.h> #include<iostream.h> void main() { int i,n; long int p=1; // or long double p=1; for exponential result which I don't...
26
by: a.mil | last post by:
I am programming for code-speed, not for ansi or other nice-guy stuff and I encountered the following problem: When I have a for loop like this: b=b0; for (a=0,i=0;i<100;i++,b--) { if (b%i)...
3
by: Sugandh Jain | last post by:
Hi. How to write a function that will return me the factorial (say in a string) for the any positive integer it takes? When we find a factorial of even say 2000 or a higher number, it will be...
26
by: y8ycgl | last post by:
i have a program that i made in my class in Turbo C++ on windows 95or98 i belive. it is made to solve for factorials. th problem is that : A) it puts it in exponents B) theres too many numbers to...
10
by: Dick Moores | last post by:
I'm writing a demo of the infinite series x**0/0! + x**1/1! + x**2/2! + x**3/3! + ... = e**x (x is non-negative) It works OK for many x, but for many the loop doesn't break. Is there a way...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.