Computer Science, asked by angelinaishwarya, 10 months ago

Remya is studying in 10th std and she was not good at maths. Her maths teacher asked to find a factorial of the given number. Can you help Remya by writing a program for the same. Input Format: The input consist of an integer Output Format: Print the factorial of a number which denotes an integer

Answers

Answered by kenvaleth
3

Answer:

def factorial(n):

    if n == 0:

      return 1

    else:

       recurse = factorial(n-1)

       result = n * recurse

       return result

n= input("which no.s factorial would you like to find?")

print (factorial(n))

Answered by pragyakirti12345
0

Answer: Java Program is given below

Concept : Factorial of a number is the product of all numbers less than or

                 equal to that given number.

Given : Input Format: The input consist of an integer

            Output Format: Print the factorial of a number which denotes an

            integer.

To Find : Write a factorial program.

Explanation:

// Writing a Java program to find factorial of a given number

import java.util.*;

class Factorial

{

// recursive method for finding factorial

static int factorial(int x)

{

 if (x == 0)

 return 1;

 else

 return n*factorial(x-1);

}

 

// Driver method

public static void main(String[] args)

{

 Scanner sc = new Scanner(System.in);

 int number = sc.nextInt();

 System.out.println("Factorial of number entered  "+ number + " is " + factorial(number));

}

}

#SPJ3

Similar questions