//problem 2.4.3// factorial_2_4_3.java: write a program tha takes an integer n and calculate n! importjava.util.Scanner;classfactorial_2_4_4{publicstaticvoidmain(Stringargs[]){Scannersc=newScanner(System.in);intnum=sc.nextInt();intfact=1;if(num<1)System.out.println("Enter a valid number...");elseif(num==1)System.out.println("Factorial value of "+num+" 1");else{while(num>0){fact=fact*num;num--;}}System.out.println("factorial value if"+fact);}}
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)