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
olga nikolaevna [1]
3 years ago
8

Without using a division or multiplication operator and without using iteration , define a recursive method named product that a

ccepts two int parameter , m and k, and calculates and returns the integer product of m times k . you can count on m>=0 and k>=0.
Mathematics
1 answer:
Fantom [35]3 years ago
8 0

I will be using the language C++. Given the problem specification, there are an large variety of solving the problem, ranging from simple addition, to more complicated bit testing and selection. But since the problem isn't exactly high performance or practical, I'll use simple addition. For a recursive function, you need to create a condition that will prevent further recursion, I'll use the condition of multiplying by 0. Also, you need to define what your recursion is.
To wit, consider the following math expression 
 f(m,k) = 0 if m = 0, otherwise f(m-1,k) + k 
 If you calculate f(0,k), you'll get 0 which is exactly what 0 * k is. 
 If you calculate f(1,k), you'll get 0 + k, which is exactly what 1 * k is.   
 So here's the function   
 int product(int m, int k) 
 { 
  if (m == 0) return 0; 
  return product(m-1,k) + k;  
}
You might be interested in
Here is an addition sentence. (13 + 5) + 5 = 23 Choose an equivalent addition sentence that shows the associative property of ad
ANTONII [103]

<span>(13 + 5) + 5 = 23
</span>
associative property of addition
<span>13 + (5 + 5) = 23</span>
6 0
3 years ago
Read 2 more answers
14. 3/64 + 2/32 + 5/16 = <br>what is the answer ​
Anit [1.1K]

Answer:

27/64

Step-by-step explanation:

(7×16)+(5×64)64×16

=112+3201/024

=432/1024

Simplifying 432/1024, the answer is

=27/64

3 0
2 years ago
Read 2 more answers
Factor these expressions into an equivalent form.
Marrrta [24]
(c+8)(c-8)

3(2y+5)(2y-5)

There are no like terms so it's still ab^2-b
7 0
3 years ago
Read 2 more answers
9+3.5g=11−0.5g<br> g=????
Hoochie [10]
Substitution. g= 1/2
3 0
3 years ago
What is a 96% confidence interval for the proportion of weight-lifting injuries in this age group that were accidental?
loris [4]
<span>A 96% confidence interval means that 96% of the time you can believe that the result will fall into a range of numbers. In the case of weight lifting this would mean that 96% of the time, the proportion of weight-lifting injuries were accidental would fall in between the two parameters set forth.</span>
8 0
3 years ago
Other questions:
  • Identify whether the graph displays a linear or nonlinear function. Explain why. Graph A On a coordinate plane, graph A goes thr
    8·2 answers
  • Find the gcf for the list. 28y4, 20y3
    12·1 answer
  • Can someone Help me please
    15·1 answer
  • Evaluate 2xy when x=-1/4 and y= 3
    10·1 answer
  • Look at the pattern below. step 1 with 1 square step 2 with 3 squares step 3 with 6 squares step 4 with 10 squares How many squa
    10·1 answer
  • What two patterns is in the table show
    12·1 answer
  • On a family vacation, Amy's dad drove the car at a constant speed and traveled 585 miles in 13 hours. At this rate, how long wou
    8·1 answer
  • Naomi says that the graph represnts a proportional relationship because it is a straight line. Is Naomi reasoning correct explai
    12·1 answer
  • A house was originally listed for sale at $250,00. After 3 months, the seller dropped the price to $235,000. What percent of dec
    6·1 answer
  • Find the measure of angle A
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!