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
This is a graph of which linear equation?
Elanso [62]
I think its is 4/5 but not positive


5 0
3 years ago
Solve for x<br> -2/5x - 8/15x + 1/3x = -54<br> x=?
Ad libitum [116K]

Answer:

x=0

Step-by-step explanation:

solve for  x  by simplifying both sides of the equation, then isolating the variable. which got me x=0

3 0
3 years ago
Read 2 more answers
What is 1+1? lol i know it’s 2
bogdanovich [222]
Lol I'll just comment to get 5 points
7 0
3 years ago
A rectangular flower garden in Samantha’s backyard has 100 feet around its edge. The width of the garden is 20 feet. What is the
SVEN [57.7K]

Answer:

bces

Step-by-step explanation:

3 0
3 years ago
Read 2 more answers
The speed you are going determines the distance you travel before coming to a complete stop after pressing the brake.
notka56 [123]

Answer: A and D

Step-by-step explanation:

4 0
3 years ago
Other questions:
  • Carpet cost $16 a square foot.A rectangular floor is 16 feet long by 14 feet wide.How much would it cost to carpet the floor
    11·1 answer
  • A computer that originally cost $850 is on sale for 15%off. What is the sale price of the computer show your work
    12·2 answers
  • PLZ HELP I BEG DUE IN 30 MIN!!! 30 POINTS!!!!
    14·2 answers
  • How can you describe the relationships among angles and sides in a triangle?
    8·1 answer
  • Find the length of arc AC express in terms of pi
    6·2 answers
  • Complete the table. *
    10·1 answer
  • In a triangle, the measure of the second angle is twice the measure of the first angle. The third angle is equal to the sum of t
    15·1 answer
  • EXPLAIN HOW MODELING SUBTRACTION WITH FRACTION STRIPS IS DIFFERENT FROM MODELING ADDITION WITH FRACTION STRIPS.
    10·1 answer
  • Freee 100 pooiinnttss!!!!! And
    5·2 answers
  • What is the answer for 7 + -3​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!