1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
xxTIMURxx [149]
3 years ago
10

In mathematics, the factorial of a positive integer n, denoted as n! , is the product of all positive integers less than or equa

l to n.
The factorial of n can be computed using the following rules.

Case I: If n is 1, then the factorial of n is 1.
Case II: If n is greater than 1, then the factorial of n is equal to n times the factorial of (n - 1).
The factorial method returns the factorial of n, as determined by case I and case II. Write the factorial method below. You are encouraged to implement this method recursively.

/** Precondition: n is between 1 and 12, inclusive.

* Returns the factorial of n, as described in part (a).

*/

public static int factorial(int n)
Computers and Technology
2 answers:
MrRa [10]3 years ago
6 0

Answer:

public static int factorial(int n) {

   

    if (n >= 1 && n <=12) {

           if (n==1)

               return 1;

           else

               return n * factorial(n-1);

    }

    else

        return -1;

}

Explanation:

Create a method called factorial that takes one parameter, n

Check if n is n is between 1 and 12. If it is between 1 and 12:

Check if it is 1. If it is 1, return 1. Otherwise, return n * function itself with parameter n-1.

If n is not between 1 and 12, return -1, indicating that the number is not in the required range.

For example:

n = 3  Is n==1, NO factorial(3) = n*factorial(2)

n = 2  Is n==1, NO factorial(2) = n*factorial(1)

n = 1  Is n==1, YES factorial(1) = 1.

Then factorial(2) = 2*1 = 2, factorial(3) = 3*2 = 6

Elis [28]3 years ago
4 0

Answer:

Explanation:

public static int factorial(int n){

if (n<=1){

return 1:

}else if (n>1 && n<=12){

return n * factorial(n - 1);

}

}

int  main() {

printf( "Enter a value :");

  scanf("%d", &n);

  printf("Factorial of %d is %d\n", n, factorial(n));

  return 0;

}

You might be interested in
Software obtained illegally is called open-source software. true / false
Oxana [17]
False, software obtained illegally is called Pirated Software.
<span>Open source software is software developed by and for the user community, ie. Linux based software is Open Source.</span>
3 0
3 years ago
You need to perform maintenance on a router and need to temporarily reroute traffic through another office. which would be the b
Whitepunk [10]
<span>In order to perform maintenance on a router and need to temporarily reroute traffic through another office  the best way to perform this action would be to configure a static route on the router.
</span>By doing this, the router will use the manually-<span>configured routing entry to send the packets.</span>
3 0
3 years ago
Which service uses a broadband connection?
Sidana [21]

Answer:

d

Explanation:

because all in one question form

5 0
3 years ago
RDBMSs enforce integrity rules automatically. <br> a. True<br> b. False
IRINA_888 [86]

It is true. RDBMS enforce integrity rules automatically. Integrity rules are automatically enforced by RDBMSs.

Integrity rules are automatically enforced by RDBMSs. Because it contains the design choices made regarding tables and their structures, a data dictionary is frequently referred to as "the database designer's database." Any character or symbol intended for mathematical manipulation may be contained in character data.

Data points that are connected to one another are stored and accessible in a relational database, which is a form of database. The relational model, an easy-to-understand method of representing data in tables, is the foundation of RDBMS. Each table row in a relational database is a record with a distinct ID known as the key.

It is simple to determine the associations between data points because the table's columns carry the properties of the data and each record typically has a value for each property.

To know more about RDBMS click on the link:

brainly.com/question/13326182

#SPJ4

8 0
1 year ago
Any computer or device on a network that can be addressed on the local network is referred to as a:
Umnica [9.8K]
<span>Any computer or device on a network that can be addressed on the local network is referred to as a: node.</span>
5 0
3 years ago
Other questions:
  • Which of the following is an important initial step in designing an interface
    7·1 answer
  • Look at the graph below. Which statement is TRUE based on the graph of an egg drop experiment?
    10·1 answer
  • If you want to wrap text so that it fits a particular cell size, which formatting section would you use?
    9·2 answers
  • Why does my Office Computer send packet #1? What device responds by sending back packet #2? What information does my Office Comp
    15·1 answer
  • What is an efficient way to ensure that the code is working as per the acceptance criteria/business requirements? (1 correct ans
    11·2 answers
  • What video game has made the most money as of 2016?
    15·2 answers
  • Project using simple formulas
    15·1 answer
  • What is one way you can learn about your digital footprint?
    13·1 answer
  • Write a program. Commence the change to be dispensed from a vending machine. An item machine can cost between $0.25 send a dolla
    9·1 answer
  • In the early 1800's, a “computer" was not a machine, it was a person who did math
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!