0
For Loops Bug?
Is there a problem with this code. I was stuck in this lesson "For Loops". I checked this code in TextPad 8 and it doesn't give me an error. import java.util.Scanner; class Demo{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int number = scanner.nextInt(); int fact = 1; for(int x=1; x<= number;x++) { fact*= x; } System.out.println(fact); } } Error is Text Case 1 Input: 14 Your Output: 1278945280 Expected Output: 87178291200 Text Case 2-5 is okay Is there a way can fix this? Other users before It got stuck this lesson are correct.
8 Antworten
+ 1
Student ,
Please don't call other people stupid, that's not respectful treatment of one another.
0
If you look to the most recent comments, you will find a new hint.
The "old" answers given by others are not corrected.
They think that "answer" is correct because there was a bug in the test case.
0
Why not just use a conditional if you know the first input?
0
Can someone have a correct answer of this?
0
Thanks.