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.

17th Nov 2018, 12:52 PM
jhodel billod
jhodel billod - avatar
12 Respostas
+ 3
Sounds like some kind of homework, to be honest. Which language? Where is your own attempt on it?
17th Nov 2018, 1:01 PM
Shadow
Shadow - avatar
+ 2
Well, okay. What have you tried so far/Where are you stuck?
17th Nov 2018, 1:07 PM
Shadow
Shadow - avatar
+ 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.
17th Nov 2018, 1:15 PM
Shadow
Shadow - avatar
+ 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
17th Nov 2018, 1:11 PM
jhodel billod
jhodel billod - avatar
+ 1
Oh you havent reset the value back after the first calculation 144000 is 120 x 2 x 3 x 4 x 5
17th Nov 2018, 1:33 PM
Taste
Taste - avatar
+ 1
Simply put fact=1 after the output
17th Nov 2018, 1:47 PM
Taste
Taste - avatar
+ 1
thank you guys
17th Nov 2018, 1:53 PM
jhodel billod
jhodel billod - avatar
0
we're using java
17th Nov 2018, 1:03 PM
jhodel billod
jhodel billod - avatar
0
the output is different from 2-5
17th Nov 2018, 1:11 PM
jhodel billod
jhodel billod - avatar
0
how do you reset the value?
17th Nov 2018, 1:42 PM
jhodel billod
jhodel billod - avatar
17th Nov 2018, 1:43 PM
jhodel billod
jhodel billod - avatar
0
can you give me guys a sample code so i can analyze it well
17th Nov 2018, 1:47 PM
jhodel billod
jhodel billod - avatar