Learning language is easy but learning basics is difficult
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Learning language is easy but learning basics is difficult
Learning language is easy but learning basics is difficult
I change to long and using BigInteger, but still getting same exception.I think long arithmetic would calculate accurate factorials up to 21! but I am not certain. For bigger numbers, use BigInteger.
Learning language is easy but learning basics is difficult
I thought it will only execute inside if block ?Tim Moores wrote:The factorial method recurses indefinitely. If the parameter is 0 or 1, it should return 0 or 1, without recursing.
Learning language is easy but learning basics is difficult
Campbell Ritchie wrote:write your factorialRecursion method using the keyword return only once. It is quite easy.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:I'm sorry, but I don't follow. I hope OP does. At least, he has now a factorial with only one return! But with one or more base cases incorporated, I would not mind two returns.
Piet Souris wrote:I'm sorry, but I don't follow.
There are two serious errors in that method.John Joe wrote:. . .
Consider Paul's rocket mass heater. |