0

Urgent

good morning. Can someone help me with a recursive method in java? I need to calculate the sum of the times the method is executed. example: I send you the number 5, you should give me back 5. Since it is called 5 times.

18th Nov 2022, 2:26 PM
Yosimar Naranjo Mancilla
Yosimar Naranjo Mancilla - avatar
1 ответ
+ 2
Can you explain a bit more? Number of method calls depends on what the method is doing. Let's say you calculate something recursive: if you want both, the result and the number of method calls you could use a static int counter. if you only want to know how often a method is called you could add a int counter to your parameter.
18th Nov 2022, 3:28 PM
Denise Roßberg
Denise Roßberg - avatar