Computer Science, asked by vaishnavi852973, 1 month ago

write a program to accept a number and print it's factorial​

Attachments:

Answers

Answered by ayush1846
2

import java.util.*;

public class fact

{

public static void main(String args[ ] ) throws exception

{

Scanner sc = new Scanner(System.in);

int i,n, f = 1;

System.out.println("Enter a number");

n=sc.nextInt();

while (i<n)

f = f * i;

i++;

System.out.println("Factorial:"+f);

return 0;

}

}

Similar questions