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]
4 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]4 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]4 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
During the troubleshooting of a pc that will not boot, it is suspected that the problem is with the ram modules. The ram modules
SOVA2 [1]

The RAM modules were not well placed or fitted firmly in the motherboard DIMM slots of the PC during toubleshooting.

What are RAM Modules?

RAM Modules have narrowly printed circuit boards that hold RAM chips (memory chips).

In order to function properly, RAM is expected to be placed or fitted firmly in the motherboard DIMM slots.

DIMM (Dual In-line Memory Module) is a module that contains one or several random access memory (RAM) chips on a small circuit board with pins that connect it to the computer motherboard.

Learn more on RAM Module here:

brainly.com/question/13308897?referrer=searchResults

#SPJ4

8 0
1 year ago
The Dark Web is _____. Select 2 options.
fiasKO [112]

Answer:

a. an international marketplace where criminals buy and sell products.

c. a capitalistic marketplace for criminals and non-criminals.

Explanation:

In computing, WWW simply means World Wide Web. The world wide web was invented by Sir Tim Berners-Lee in 1990 while working with the European Council for Nuclear Research (CERN); Web 2.0 evolved in 1999. Basically, WWW refers to a collection of web pages that are located on a huge network of interconnected computers (the Internet). Also, users from all over the world can access the world wide web by using an internet connection and a web browser such as Chrome, Firefox, Safari, Opera, etc.

In a nutshell, the world wide web (www) is an information system that is generally made up of users and resources (documents) that are connected via hypertext links.

The dark web also referred to as darknet, can be defined as a subset of the world wide web that is intentionally encrypted from conventional web browser and search engines. Thus, it is a peer-to-peer network that requires the use of specialized configuration and web browser such as "Tor browser" in order to access its contents.

Generally, all the internet activities carried out on the dark web are anonymous and private, thereby making it suitable for either legal or illegal operations. Also, it's devoid of government influence or control and as such it's typically a capitalistic marketplace, where goods and services are privately owned and controlled by the people.

Hence, we can deduce that the dark web is simply;

I. An international marketplace where criminals buy and sell their products.

II. A capitalistic marketplace for criminals and non-criminals.

4 0
3 years ago
Write a program. in QBAsSIC
goblinko [34]

Answer:

The program is as follows:

<em>5 INPUT A,B</em>

<em>6 PROD = A * B</em>

<em>7 PRINT PROD</em>

<em>8 TOTAL = A + B</em>

<em>9 PRINT TOTAL</em>

<em>10 DIFF = A - B</em>

<em>11 PRINT DIFF</em>

<em>12 END</em>

Explanation:

This gets input for the two numbers

<em>5 INPUT A,B</em>

This calculates the product

<em>6 PROD = A * B</em>

This prints the calculated product

<em>7 PRINT PROD</em>

This calculates the sum

<em>8 TOTAL = A + B</em>

This prints the calculated sum

<em>9 PRINT TOTAL</em>

This calculates the difference

<em>10 DIFF = A - B</em>

This prints the calculated difference

<em>11 PRINT DIFF</em>

This ends the program

<em>12 END</em>

5 0
3 years ago
A company is building an expert system for use in stock trading. In which part will they have to invest the most if they have to
Korolek [52]
The answer is C because they need to store a massive amout of data
4 0
3 years ago
A _________, such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.
Serga [27]

A <u>domain name </u>such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.

What is Domain name?

This is known to be a kind of Application programming interface. The  domain name is said to be a series or a string of letters that tells more about a realm of administrative autonomy.

It  tells about authority as well as control that is found  within the Internet. Domain names are said to be used in a lot of networking contexts and therefore, A <u>domain name </u>such as apple.com and whitehouse.gov, uniquely identifies a site and a brand on the web.

Learn more about Domain name from

brainly.com/question/13153286
#SPJ1

5 0
2 years ago
Other questions:
  • Which view is used to allow a publisher to view facing pages of a publication at the same time?  NormalMaster PageTwo-Page Sprea
    9·1 answer
  • What is the amount of money you still owe to their credit card company called?
    5·2 answers
  • Which is true about POP3 and IMAP for incoming email?
    6·1 answer
  • An indicator is a comprehensive analysis of critical information
    8·1 answer
  • John would like to move from the city into the suburbs and has been saving up a large down payment for a home. Which is the most
    7·1 answer
  • When doing career research online, you always want to make sure you are viewing a reliable source, what factors about the websit
    10·2 answers
  • How should the teachers respond to the parental complaints of student C? If they fail the student, the student will likely be re
    11·1 answer
  • Which of these communication avenues is not regulated by the Federal Communications Commission (FCC)?
    12·1 answer
  • An understanding of basic psychology can help design and marketing teams ensure they meet their intended audience.
    15·2 answers
  • When charlie attaches a file to an email message, the computer's __________ is responsible for managing his access to the locati
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!