I need help with Java 16.2. My Code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int number = scanner.nextInt(); int fact = number; //your code goes here while (number > 1){ fact = number * number--; number = number--; } System.out.println(fact); } }
1/25/2022 6:55:04 PM
David14 Answers
New AnswerInside the loop needs to be: fact = fact * number; // update fact number--; // decrease number once
But what helps me that? Because I want the number to always be lowered by one so that the program stops at the end.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message