0
Help pls
Step 1. Ask the user to enter a positive integer Step 2. Check if the entered integer is positive or negative. If it is positive perform Step 3, otherwise, display an appropriate error message and the program should stop. Step 3. Calculate the factorial of the entered positive integer and display the result. Note: The factorial of n is denoted by n! and calculated by the product of integer numbers from 1 to n. For example, the entered integer is 5, the calculation of its factorial is: 5! = 1 × 2 × 3 × 4 × 5 = 120. Step 4. Repeat Step 1 to Step 3 five (5) times. 5. Compile and execute the program.
12 Antworten
+ 3
Sounds like some kind of homework, to be honest. Which language? Where is your own attempt on it?
+ 2
Well, okay. What have you tried so far/Where are you stuck?
+ 2
That's interesting. Can you maybe link the program here so we can have a look at it?
Without seeing it, it seems you forgot to reset whatever variable holds the result back to 1.
+ 1
output:
1st
--------------------
enter a positive no.:
5
1 x 2 x 3 x 4 x 5
the factorial of 5 is 120
2nd
enter a positive no.:
5
1 x 2 x 3 x 4 x 5
the factorial of 5 is 144000
+ 1
Oh you havent reset the value back after the first calculation
144000 is 120 x 2 x 3 x 4 x 5
+ 1
Simply put fact=1 after the output
+ 1
thank you guys
0
we're using java
0
the output is different from 2-5
0
how do you reset the value?
0
can you give me guys a sample code so i can analyze it well