Computer Science, asked by shagun2822, 4 months ago

write a program in java to enter a number and print the factorial value of each digit​

Answers

Answered by ishitajadhav97
0

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);    

}  

}  

Answered by udayagrawal49
1

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.

Similar questions