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]
2 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]2 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
A small plant is 212 inches tall. How tall will it be in 3 weeks if it grows 34 inch each week? Which method will NOT give the c
Neporo4naja [7]
34*3=102 hope this helps so 102 is the answer please give me brainliest
5 0
3 years ago
Read 2 more answers
HELP PLEASE! I'm not sure what the answer is.
Anuta_ua [19.1K]
The answer for this are (10,2), (8,1), and (14,-1).
7 0
3 years ago
Read 2 more answers
A family has a yearly income or $60,000. They want to spend no more than 30% of their income on rent for their house . How much
mixas84 [53]

<em>18000. 30% of 60,000 is 18,000</em>

5 0
3 years ago
Read 2 more answers
Jerry went for an 18-mile bike ride and got a flat after he completed 2/9 of his trip. How many more miles of the trip does Jerr
valina [46]

Answer:

Jerry has to complete 14 more miles

Step-by-step explanation:

\frac{2}{9} × 18 = 4

18 - 4 = 14

7 0
3 years ago
What is the additive inverse of -40
goldfiish [28.3K]

Answer:

The additive inverse of -40 is 40

Step-by-step explanation:

The additive inverseof a number is the oppositeof that number so you would change the sign.

if you need to add them it would be

(-40)+40= 0

5 0
2 years ago
Read 2 more answers
Other questions:
  • Solve for A<br> 3(4A + 4) = 3A + 8A + 1 + 8
    10·1 answer
  • If 8% of all cell phones are defective, and you have a random sample group of 100 Samsung Galaxy Vills,
    6·1 answer
  • Express as a single natural logarithm.<br> ln 16 - ln 8<br> A. ln 2<br> B. ln 8<br> C. ln 128
    5·2 answers
  • Find the image of the given point under the given translation!!!! help please!!!!​
    6·1 answer
  • A classroom has 35 glue sticks if the ratio of glue sticks to glue bottles what is 5:2 how many glue bottles did the classroom h
    10·2 answers
  • Correct answers only please!
    13·1 answer
  • (07.03)
    10·2 answers
  • Answer this please tell me if I’m correct
    9·1 answer
  • George is going to sing 4 songs in
    13·2 answers
  • HELP ASAP<br> f(x)=x² what is g(x)?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!