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
soldier1979 [14.2K]
3 years ago
6

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or e

qual to n. For example, 5!=5 *4* 3* 2* 1 =120 Write a programn (in Java) to print and calculate the factorial for a given (n) number
Computers and Technology
1 answer:
Daniel [21]3 years ago
3 0
I'll show a few implementations, starting with the easiest to understand.

1.) While loop.

public static void main(String[] args) {
System.out.print(factorial(n));
}

public static int factorial(String n) {
int result = 1;
while(n > 0) {
result *= n;
n--;
}
return result;
}


2.) For loop (I'll just show the contents of the factorial(String) method):

int result = 1;
for (int i = n; i > 0; i--) {
result *= i;
}
return result;


3.) Recursively.

public static int factorial(int n) {
if(n == 1) return n;
return n * factorial(n-1);
}
You might be interested in
Elabora un argumento sobre como nuestras acciones impactan en la calidad del aire y promueven acciones a favor del cuidado del a
ryzh [129]
<h2>Answer:</h2>

Reduzca la cantidad de viajes que realiza en su automóvil. Reduzca o elimine el uso de chimeneas y estufas de leña. Evite quemar hojas, basura y otros materiales. Evite el uso de equipos de jardín y césped que funcionen con gas.

<h3>#CarryOnLearning</h3>

4 0
3 years ago
Some websites create libraries specifically of writing that is in the public domain. What if the advantage of this?
dedylja [7]

Answer:

To provide further literature on particular issues of relevance

Explanation:

Libraries are specifically meant to provide readers with more information and knowledge. In other words, they enable you gain a sound knowledge on the issues you seek to know more about either in terms of product and services of the primary goal of the website, if necessary.

5 0
4 years ago
I’ll give brainliest
Stolb23 [73]

Answer: ] Data moving to the cloud puts it at risk for malware. Increasing user mobility and results in data taken outside of an organization’s security perimeter, exposing their business to risk. Cloud services pose security challenges putting pressure on security teams, thus fueling the growth of . The basic pillars or features of  are Visibility, Access Control, Threat Protection, Data Security, and Compliance. Two camps are emerging: pure plays and large security vendors adding to a broad cloud security solution. Several startups are emerging and there has been intense M&A activity in recent years. Cloud apps are a new opportunity for hackers to gain access to an organization's data and its network.  has developed quickly from just being used for shadow IT. It is an important tool to monitor cloud usage and also implement security.  is a small but fast growing market in a state of flux.

Explanation:

6 0
3 years ago
A(n) ________ is a program that takes advantage of very low-level operating system functions to hide itself from all but the mos
Rufina [12.5K]

Answer:

a rootkit is a program that takes advantage of very low-level operating system functions

Explanation:

6 0
2 years ago
Which is not a component of a database that describes how data is stored?
valentinak56 [21]
<span>Which is not a component of a database that describes how data is stored?

</span>
5 0
4 years ago
Other questions:
  • Gross Domestic Product is equivalent to which of the following?
    13·1 answer
  • The default primary key for an access database is the id field true or falser
    7·1 answer
  • Is cloud computing a hardware service used to keep computers working? True or False
    11·1 answer
  • In a digital computer system, the data is transferred between the CPU and the other components
    11·1 answer
  • Match each role to the corresponding web development task.
    14·1 answer
  • Select three advantages of cloud computing.
    12·1 answer
  • What is the main difference between inserting header/footer in excel and word?​
    11·1 answer
  • HELP ME PLEASE <br> Can you help get back my ro blox account: (LOLCrashForce)
    15·2 answers
  • The choice of database does not have any impact on the relevancy of search results?
    13·1 answer
  • Alice's public key, and sends back the number R encrypted with his private key. Alice decrypts the message and verifies that the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!