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.

29th Oct 2023, 11:40 AM
Joseph M. Generale
Joseph M. Generale - avatar
8 Respuestas
+ 1
Student , Please don't call other people stupid, that's not respectful treatment of one another.
2nd Nov 2023, 10:28 AM
sandra
sandra - avatar
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.
29th Oct 2023, 2:01 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
Why not just use a conditional if you know the first input?
30th Oct 2023, 8:41 PM
Annihilate
Annihilate - avatar
0
Can someone have a correct answer of this?
1st Nov 2023, 9:41 PM
Joseph M. Generale
Joseph M. Generale - avatar
0
Thanks.
2nd Nov 2023, 2:34 AM
Joseph M. Generale
Joseph M. Generale - avatar