Computer Science, asked by SmileAngel2000, 1 year ago

Write a java program (using any of these: if, if-else, while, do-while, for) to print factorial of any given number.

Answers

Answered by kooper
1
//To find the factorial of 10 using do-while statement.
public class factorial
{
public static void main(String args[])
{
int i,f ;i=1;f=1;
do
{
f=f * i ;
i++
}
while(i<=10);
System.out.println("The factorial of 10 = "+f);
}
}

*************************HOPING THAT THIS WILL HELP YOU!!!**********************

kooper: Plz mark it as best!!!............... : )
Answered by tithi
0
import java.io.*;
class fact
{
int fac(int a)
{
if(a=0)
return(1);
else
return(n*fac(n-1));
}
public static void main(String args[])
{
int b;
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read) ;
System.out.println("Enter the number");
b=Integer.parseInt(in.readLine());
fact ob=new fact;
ob.fac(b);
}
}
hope i helped u:)

tithi: plzzzzz mark as best
Similar questions