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
Mnenie [13.5K]
3 years ago
6

Write a program that lets a user enter n and that outputs n! (meaning n*(n-1)*(n-2)*...*2*1). hint: initialize a variable totalv

alue to n, and use a loop variable i that counts from n-1 down to 1. c++
Computers and Technology
1 answer:
Elis [28]3 years ago
5 0
#import<iostream>
using namespace std

int main() {
    cout << "without recursion: " << factorialWNR(6) <<"\n";
}
//WNR = with no recursion
int factorialWNR(int n) {
    int totalvalue=1;;;;;;;;;;;;;;
    for (n; n >= 1; n--){
        totalvalue*=n;
    }
    return totalvalue;
}
int factorialWR(int n){
    if (n == 1) return 1;
    else return n * factorial(n - 1);
}
// if I missed something report my message.

You might be interested in
......acts as a platform on which application software runs.
dexar [7]

System software acts as a platform on which an application software program runs. Hope this helps!

8 0
3 years ago
Converting Denary to Binary
Dmitrij [34]

Answer:

Converting the numbers provided to decimal:

128: 10000000

64: 01000000

32: 00100000

16: 00010000

1: 00000001

56: 00111000

121: 01111001

45: 00101101

132: 10000010

245: 11111001

4 0
3 years ago
The top element in the hierarchy is the html element , which contains all of the other elements within a Hypertext Markup Langua
Anna [14]

the answer is true

The top element in the hierarchy is the html element

6 0
4 years ago
A computer professional who has access to sensitive information shares this information with a third party. Which professional c
GalinKa [24]

Answer:

The answer is c.

Explanation:

hope this helps

7 0
4 years ago
Suppose you repeatedly roll a fair six-sided die until you roll a 1 (and then you stop). Every time you roll a 2, you lose a poi
OverLord2011 [107]

Answer:

E = b-a

Explanation:

In this questions what we are been asked is for the expected value E, to solve the problem we need to recognize the random variables and their respective probability.

  • x1 = roll a 1 -> P1 = 1/6
  • x2 = roll a 2 -> P2 = 1/6
  • x3 = roll a 6 -> P3 = 1/6
  • x4 = roll a 1, 4 or 5 -> P4 = 1/2

E = P1*x1 + P2*x2 + P3*x2 + P4*x4

x1 is equal to zero (no points and the game stop), x2 is equal to E-a (lose a points, affecting the expected value), x3 is equal to E+b (win b points, affecting the expected value) and x4 is equal E (no points are lost and the game continues, therefore the expected value is not affected)

E = 1/6*0 + 1/6*(E-a) + 1/6*(E+b) + 1/2*(E)

1/6*E = 1/6*b - 1/6a

Solving for E

E = b-a

Conclusion: If you get a 3, 4 or 5 the game is unaffected (in terms of points), you need to pay special attention to x1, x2 and x3 (all with the same probability)  that are the results that are going to affect your game.  

7 0
3 years ago
Other questions:
  • Connie decided that her paper should be organized in the order in which the events happened. What type of organizational method
    15·1 answer
  • What term is defined as private data placed in a packet with a header containing routing information that allows the data to tra
    13·1 answer
  • The function of the file server is to : 1. store data and software programs that can be used by client computers on the network.
    12·1 answer
  • A user complains that his new mouse doesn't work right. He has an old system at home and when he has had this problem, he cleane
    15·1 answer
  • What is essence of computer systems and networks?​
    9·1 answer
  • PLEASE ANSWER ASAP
    5·1 answer
  • Write a program that will input miles traveled and hours spent in travel. The program will determine miles per hour. This calcul
    5·1 answer
  • A system of classifying and organizing online content into categories by the use of user-generated metadata such as keywords is
    8·1 answer
  • Given a list of twenty number count the numbers among the list
    7·1 answer
  • 15. You read a news article that's politically biased and not well organized. It's
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!