public static void factorial() {
Scanner scanner=new Scanner(System.in);
int a;
int fac = 1;
System.out.println("Kiritilgan sonni faktorialini aniqlash!");
System.out.print("Sonni kiriting: ");
a=scanner.nextInt();
for (int i = 1; i <= a; i++) {
fac=fac*i;
}
System.out.println(fac);
}
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