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]
3 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]3 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
Three joggers are running around a circular track. One of them completes one lap in 6 minutes, the second one in 9 minutes, and
Anettt [7]

Answer:

At 11:30 am they will arrive at their starting point together

Step-by-step explanation:

we know that

One of them completes one lap in 6 minutes

The second one in 9 minutes

The third one in 15 minutes

step 1

Find the least common multiple (LCM)

6=2*3

9=3²

15=3*5

so

LCM=(3²)*(2)*(5)=90 minutes

step 2

Find the number of laps of each jogger for the LCM

jogger 1

90/6=15 laps

jogger 2

90/9=10 laps

jogger 3

90/15=6 laps

If they start at 10:00 am

then

10:00 am + 90 minutes=11:30 am

4 0
3 years ago
How do you do <br> (x+y)(x-5y)+3(x+y)^2<br> ???? <br> Emergency, please help with full steps
Naddik [55]

Answer:

4 {x}^{2}  + 2xy - 2 {y}^{2}

Step-by-step explanation:

(x + y)(x - 5y) +  {3(x + y)}^{2}  \\ x(x - 5y) + y(x - 5y) + 3(x + y)(x + y) \\  {x}^{2}  - 5xy + xy - 5 {y}^{2}  + (3x + 3y)(x + y) \\  {x}^{2}  - 4xy - 5 {y}^{2}  + 3x(x + y) + 3y(x + y) \\  {x}^{2}  - 4xy - 5 {y}^{2}  + 3 {x}^{2}  + 3xy + 3xy + 3 {y}^{2}  \\  {x}^{2}  - 4xy - 5 {y}^{2}  + 3 {x}^{2}  + 6xy + 3 {y}^{2}  \\  {x}^{2}  + 3 {x}^{2}  - 4xy + 6xy - 5 {y}^{2}  + 3 {y}^{2}  \\ 4 {x}^{2}  + 2xy - 2 {y}^{2}

7 0
3 years ago
If a line with a slope of -2 crosses the y-axis at (0, 3), what is the equation of the line?
zhannawk [14.2K]
-2=3x+0 Would Be The Equation
8 0
3 years ago
Yvonne has a goal of buying a brand new home within a year. She's afraid that she will be unable to save the money that she need
Luba_88 [7]

Answer:

where is the multiple choice

Step-by-step explanation:

5 0
3 years ago
Read 2 more answers
A freight train completes its journey of 150 miles 1 hour earlier if its original speed is increased by 5 miles/hour what is the
vlabodo [156]
<span>A freight train completes its journey of 150 miles 1 hour earlier if its original speed is increased by 5 miles/hour. What is the train’s original speed?
***
let x=original speed
x+5=increased speed
travel time=distance/speed
..
lcd:x(x+5)
150(x+5)-150x=x(x+5)
150x+750-150x=x^2+5x
x^2+5x-750=0
(x-25)(x+30)=0
x=25
What is the train’s original speed? 25 mph</span>
7 0
3 years ago
Other questions:
  • What is triangle similarity
    5·1 answer
  • Which of the following are the coordinates of the vertex of y = −x2 + 2x + 1
    10·1 answer
  • Which list shows the volumes in increasing order? A) A, B, C B) A, C, B C) B, A, C D) C, A, B
    14·1 answer
  • A manufacturer of cheese filled ravioli supplies a pizza restaurant chain. Based on data collected from its automatic filling pr
    14·1 answer
  • Can someone help me plz
    9·2 answers
  • Suppose that 50% of the watches produced by a certain factory are defective. A store buys a box with 400 watches produced by thi
    15·1 answer
  • Because why not ??? ?????
    9·1 answer
  • En la papelería " Office Depot", una caja con 24 plumones cuesta $120 y en la papelería "Dabo" una caja con 18 plumones cuesta $
    12·1 answer
  • In a month with 31 days, Google featured Doodles on 18 days.What percent of the month was this?Round to the nearest whole percen
    8·1 answer
  • The product of two powers is 11^8 and their quotient is 11². What are the two powers? Explain.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!