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
mote1985 [20]
2 years ago
9

Using pseudo-code, describe a recursive algorithm to find n! mod m, when m, n ? Z+.

Mathematics
1 answer:
Nadya [2.5K]2 years ago
3 0

Explanation:

A recursive algorithm has a terminating condition and a recursive rule.

The function "facMod" will terminate with an output of 0 if m ≤ n, because m would be a factor of n!. It will terminate with an output of 1 if n < 2.

Otherwise, it is the product mod m of n and the "facMod" of n-1.

  • facMod(m, n) : = If( m ≤ n, 0, If( n < 2, 1, Mod(n*facMod(m, n-1), m)))

__

In this code, the If(a, b, c) statement returns b for a=true, otherwise it returns c. The Mod(a, b) statement returns a modulo b.

You might be interested in
Occasionally an airline will lose a bag. Suppose a small airline has found it can reasonably model the number of bags lost each
julia-pushkina [17]

Answer:

a) The probability that the airline will lose no bags next monday is 0.1108

b) The probability that the airline will lose 0,1, or 2 bags next Monday is 0.6227

c) I would recommend taking a Poisson model with mean 4.4 instead of a Poisson model with mean 2.2

Step-by-step explanation:

The probability mass function of X, for which we denote the amount of bags lost next monday is given by this formula

P(X=k) = \frac{e^{-2.2} * {2.2}^k }{k!}

a)

P(X=0) = \frac{e^{-2.2} * {2.2}^0 }{0!} = 0.1108

The probability that the airline will lose no bags next monday is 0.1108.

b) Note that P(X \in \{0,1,2\} = P(X=0) + P(X=1) + P(X=2) . And

P(X=0)+P(X=1)+P(X=2) = e^{-2.2} * (1 + 2.2 + 2.2^2/2) = 0.6227

Therefore, the probability that the airline will lose 0,1, or 2 bags next Monday is 0.6227.

c) If the double of flights are taken, then you at least should expect to loose a similar proportion in bags, because you will have more chances for a bag to be lost. WIth this in mind, we can correctly think that the average amount of bags that will be lost each day will double. Thus, i would double the mean of the Poisson model, in other words, i would take a Poisson model with mean 4.4, instead of 2.2.

6 0
3 years ago
Convert 2/50 to percent
vodomira [7]

Answer: 4%

Step-by-step explanation: 50 x 2 = 100

2x2=4 4/100 or 4%

8 0
3 years ago
Read 2 more answers
Can you help me solve this?
Wittaler [7]

Answer:

y=-1/2x+4 Is your answer

Step-by-step explanation:

y=mx+b

3=2x+4

-1=2x

x=-1/2

You already know y is 4 so y=-1/2x+4

4 0
3 years ago
Hello!! I have a question, can you please answer it. ^^
xeze [42]

Answer:

1. 75

2. 1

Step-by-step explanation:

5 0
3 years ago
Negative plus a positive equals
Sergeu [11.5K]

Answer:  multiplied together or divided, the answer is positive. If two negative numbers are multiplied together or divided, the answer is positive.

Step-by-step explanation:

4 0
3 years ago
Other questions:
  • PLZ HELP ME!!!!!! ASAP!!!!! I WILL GIVE BRAINLIEST!!!!!!!!!!!
    13·2 answers
  • A rectangle has a length of 11 inches and a width of 7 inches. If the length is increased by xx inches and the width increased b
    9·1 answer
  • if you give someone 50$ then take 64$ then your give 2$then a man gave you another dollar and said double or nothing and you got
    11·2 answers
  • PLEASE HELP ASAP DUE IN 10 MINUTES PLEASE!!!!!!!!!!!!!The president of the United States produces a new national plan to reduce
    8·1 answer
  • Which graph represents a line with a slope of and a y-intercept equal to that of the line y = x – 2?
    13·2 answers
  • NEED ANSWER NOW!!!!!!!!!!
    5·2 answers
  • Area of triangle please help
    13·2 answers
  • 1.Morgan drives 24 miles due north, then drives 7 miles due east from home to work. What is the distance between Morgan’s home a
    6·1 answer
  • Solve the following by completing the square y=x^2+10
    7·1 answer
  • Two stores sell CDs in packages, as shown in the table below. Number of CDs in Package Cost Number of CDs in Package Cost CD Pri
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!