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
20 red marbles to 40 blue marbles (ratio as a fraction)
Tanya [424]

Answer:

20/40 = 10/20 = 1/2, 1:2

Step-by-step explanation:

I hope this helped and if it did I would appreciate it if you marked me Brainliest. Thank you and have a nice day!

3 0
2 years ago
Read 2 more answers
Afla sesimea numarului 5489 .<br> cincimea unui numar este 85.afla numarul.
Airida [17]
Sprry, I don't speak spanish, really wish I could've helped. If anyone reading this knows spanish, please comment and tell me what the question is asking.
7 0
3 years ago
Figure A
Amiraneli [1.4K]
<h2>Answer:</h2>

Figure B

<h2>Step-by-step explanation:</h2>

The Pythagorean Theorem is a^2 + b^2 = c^2, where c is the longest side of the triangle (the hypotenuse).

To find the side length of each square, you have to square root the area of each square. This means that Figure A has side lengths of 3, 6 and 8 units. Figure B has side lengths of 5, 12 and 13 units.

In Figure A, if the triangle is right-angled, the equation 3^2 + 6^2 = 8^2 must be correct. 9 + 36 = 45. 45 is not equal to 64, so the triangle is not right-angled.

In Figure B,  if the triangle is right-angled, the equation 5^2 + 12 ^2 = 13^2 must be correct. 25 + 144 = 169. 169 is 13 squared, so the triangle is right-angled.

Alternatively, as you are already given the square values for each side length, there is no need to square root and square again. You can just test if the two smaller areas equal the larger area, but the explanation above uses a more detailed example of the Pythagorean Theorem.

8 0
2 years ago
Read 2 more answers
Prince Ivan rides gray wolf and a constant speed from kings castle to the magic apple garden in five hours. on the return trip t
borishaifa [10]

Answer:

The original speed of the grey wolf can be 9 and/or 48 km/hour

Step-by-step explanation:

There are two trips. One to King Castle (KC) to Magic Apple Garden (MAG), and then back (MAG - KC).

First trip: KC - MAG

It takes the same distance as MAG - KC so distance can be D for both.

Then it is stated that it takes 5 hours or 300mins for him to go from KC - MAG, and the speed is constant.

Let x be speed.

So the equation for this is:

D=5x

Second trip: MAG - KC

Here he goes 36 mi at constant speed (x), then picks up his speed by 3 km/hour (x+3).

For Time:

He reaches to KC, 15 mins earlier than KC - MAG, so he reaches there in 4.75 hours or in 275 min.

The problem splits into two as there are two different times, for the two parts of the journey or distance for MAG - KC.

Let T#1 = a, and T#2 = b.

Let D#2 = D-36

The equation for a:

a = 36/x --> This is he is at a constant speed and went for 36mi.

Next:

The equation for b:

b = (x+3)/D#2

These two equation have to be added as (a+b) = 4.75 --> 4.75 is the total time for MAG - KC.

So the equation is:

36/x + (5x-36)/x+3 = 4.75 --> Knowing (a+b) = 4.75, just put 4.75 as the equal, and add the fractions that equal (a) and (b).

Now Solve:

36/x + (5x-36)/x+3 = 4.75

0.25s^2 + 108 + 5s^2 - 36s = 4.75s*(s+3)

0.25s^2 - 14.25s + 108 = 0

(14.25 +- Square root (203.06 - 108))/0.5

(14.25 +- Square root (95.0625))/0.5

(14.25 +- 9.75)/0.5

Answer:

s = 9, s=48.

Therefore the original speed of the grey wolf can be 9 and/or 48 km/hour.

8 0
3 years ago
How do you round 784,392 to the nearest ten thousand
harina [27]
The answer is 780,000.
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the product?<br> 3x [-6 -11<br> 1-14 -9]
    7·1 answer
  • The function c(x)=6+8x gives the cost in dollars to rent one bicycle for x hours. What is the meaning of c^-1(10) in this situat
    10·1 answer
  • Use the graph below for this question: graph of parabola going through negative 5, 1 and negative 4, negative 4. What is the ave
    12·1 answer
  • Once a week you babysit your neighbor’s toddler after school, usually going to a local playground. You notice that each swing on
    7·1 answer
  • Can someone help ASAP!!!
    15·1 answer
  • -2x + 3(-4x + 6) =116<br> What is it
    8·2 answers
  • Will give brainliest<br><br>gimme some good songs
    9·1 answer
  • Help please!!!!
    5·1 answer
  • Convert 6400000 milligrams to kilograms
    9·2 answers
  • Write down the equation for the following expression and then solve it.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!