Set factorial to 1
While N is not equal to 0
Set factorial=factorial*N
Set N= N-1
End While
Display factorial

3
Contributors
11
Replies
12
Views
7 Years
Discussion Span
Last Post by finito

What have you done so far? in codeing that is

what i have done is this:

String factorial;//declare variable factorial

``````factorial=1;
While N != 0
{
factorial*N=factorial;
N--;
}

DisplayLabel.Text=factorial.ToString``````

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Where is the user input?
Why is factorial a string?
Why are you assigning an integer to a string?
That while statement won't compile.
The factorial assigment statement is incorrect.
The final statement will not compile.

Then may i know what is the right way to do please?

Where is the user input?

Where is N defined, N is the input
Get the input from the user.

Why is factorial a string?

Make factorial an integer

Why are you assigning an integer to a string?

I think he was saying why are you assigning it as string where it should have been an integer

That while statement won't compile.

The factorial assigment statement is incorrect.

factorial*N=factorial; where did you learn programming man?
its factorial = ;

The final statement will not compile.

You are missing a ;

did you try to compile this?

I can see you are very new to programming. Which is OK, please tell me if you need further clarification.

thanks fpr helping and ya im very new to programming.just started 2 weeks ago.i need great help...im like cracking my head on how to programming the right way for certain applications right now.

ok please mark as solved if solved.

Visual studio still does'nt run this program right.what is wrong with my code.what can i do to run the program well?

this is what i added in the coding:

``````    private void button1_Click(object sender, EventArgs e)
{
int factorial;
factorial=1;

While (N != 0);
{
factorial= factorial*N;

N--;
}
factorialDisplay.Text = factorial.ToString;
``````

Edited by mike_2000_17: Fixed formatting

you haven't initialized N.

factorialDisplay.Text = factorial.ToString();

What is the Error. If you read it you should be able to tell.

you haven't initialized N.

factorialDisplay.Text = factorial.ToString();

What is the Error. If you read it you should be able to tell.

is it supposed to be
factorialDisplayLabel.Text=Convert.ToInt();

try factorialDisplay.Text = factorial+"";

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.