Computer Science, asked by kritika2727, 1 year ago

write a program to find factorial of a number using while loop

Answers

Answered by Rajdeep11111
6
import java.io.*;
class Factorial
{
public static void main (String args[])
{
BufferedReader buff = new BufferedReader (new InputStreamReader(System.in);
System.out.print("Enter a number: ");
int num = Integer.parseInt(buff.readLine());
int i = 1, fact = 1;
while (i <= num)
{
fact = fact * i;
i++;
}
System.out.println(" Factorial is : " + fact);
}
}
Similar questions