0
Help, What part of the code should I modify?
The code has no output when I enter the value 15, 20, and 25 in parameter 1 https://code.sololearn.com/cneH702wD1y1/?ref=app
6 ответов
+ 1
Presently, the code is computing n!*20, and doing it by addition via tail recursion. Fortunately, it is not too hard to convert repeated addition into multiplication, and from tail recursion into a simple loop. However, in this case I would not even try a conversion. I think it would be easier just to write a factorial-calculating loop. Then multiply the result by 20.
+ 1
It accepting..
Do you mean about no output?
0
Yes, there is no output when I enter the value 15, 20, and 25 in my method factorial
0
What are you trying by the factorial method? Oh..You are making recursion 300+ calls for input sample 5.
Above 10 input, you are getting sololearn execution timeout. What is value 20 there?
0
Edward it is very likely that the program is blowing up the stack. With 15 as input, your factorial function is attempting 2,615,348,736,000 recursive calls. You might want to revamp the algorithm.
0
Is there any way to fix the problem?