import java.util.*; class Factorial { public static void main (String[] args) { int fact=1; int n,i; Scanner s = new Scanner(System.in); System.out.print("Enter Number "); n = s.nextInt(); for(i=1;i<=n;i++) { fact = fact*i; } System.out.println("Factorial of "+n+"is "+fact); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter