Write a Java program to print the factorial of a given number.(Example: Factorial of 5= 5*4*3*2*1 = 120 & Factorial of 8= 8*7*6*5*4*3*2*1 =40,320 etc.
Answers
Answered by
4
Answer:
CHECK OUT MY SOLUTION
import java.util.*;
public class factorial {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please enter the number ou want to factorial: ");
int num = input.nextInt();
int result = 1;
for(int i = 1; i <= num; i++) {
result *= i;
}
System.out.println("The result is: "+ result);
}
}
Explanation:
MARK ME BRAINLIEST!
Answered by
0
Answer:
Explanation:
what is java??
Similar questions