write a program in java to enter a number and print the factorial value of each digit
Answers
Answer:
here is your answer mate
Explanation:
class FactorialExample{
public static void main(String args[]){
int i,fact=1;
int number=5;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i;
}
System.out.println("Factorial of "+number+" is: "+fact);
}
}
Answer: The required java program is :-
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter a number");
int num = scan.nextInt();
scan.close();
String numD = ""+num;
int numDigits = numD.length();
int sum , digit ;
while(num>0){
digit = num%10;
int proD = 1;
for(int i=1 ; i<=digit ; i++){
proD *= i;
}
System.out.println("Factorial value of "+digit+" is "+proD);
num /= 10;
}
}
}
Please mark it as Brainliest.