Computer Science, asked by daphne, 1 year ago

wap to accept a number and print its factorial using while loop......whoever answers it first I will select it as brainliest answer
*remember it should be correct. ..

Answers

Answered by legerdemain
1
import java.io.*;
public class Factorial
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int n, i=1, fact=1;
System.out.print("Enter a number:- ");
n=Integer.parseInt(br.readLine());

while( i != n )
{
fact=fact*i;
i++;
}

System.out.println("The factorial is " + fact);
}
}
Answered by shazaya
1

class programme

{

public static void main (int n)

{

int f=1

for (int i=1;i <=n;i++)

{

f=f*i;

}

System.out.println ("factorial of the no:"+f);

}

}

Similar questions