import java.util.*;
public class WhileFactorial {
public static void main(String[] args)
{
System.out.println("Enter a number");
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int fact=1;
while (num !=0)
{
fact = fact * num;
num-=1;
}
System.out.println("Factorial of the number is "+fact);
}
}
You have added a semicolon to while that completely changes the meaning of using while here.