Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
n, n-1, ..., 1
via ArgumentCaptors since you can just callfactorial(0)
n-1
times and then calculate with a for loop or so. Additionally the recursion should not force to stop atn==1
but could also go ton==0
so exactlyn
times is too restrictive. Also I would recommend to use a bigger value for this test asn==2
can be rolled and this not really representative value to check for recursion.n==20
in the random tests without overflowinglong
range.org.junit.jupiter.params.ParameterizedTest
andorg.junit.jupiter.api.RepeatedTest
Hello @user8436785 ,
Forked and added this translation - https://www.codewars.com/kumite/5d0437ab11bd8c002086eeaa?sel=62b6cf6d0ee74b011f9f9458
Please use Java 11.
Please don't use
public
for the reference solution...This comment is hidden because it contains spoiler information about the solution
OK this it's resolved. Even if this kata isn't accepted, I learned how to inject bytecode at Java Runtime, so it's a win :)
In Java, test that a method is called recursively is a pain in the ass, it took me 4 hours.
You're right, I was to hasty to publish this kata, I'll fix it and publish it later. Thanks !
You're right, fixed
None of the "restrictions" are actually present.
Duplicate.
The tests are not runnable.The initial solution is wrong. The expected data type is
long
(at least the author usedlong
in his solution).