While also works like for just you need to be manipulative with the initialization and conditions.
You can take a reference from this program.
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);
    }
}