Closed m4mario closed 2 months ago
In function
func factorial() -> Double
This line is the problem
for i in 2 ..< Int(self)
Changing it to this fixes the issue.
for i in 2 ..< Int(self+1.0)
At first I thought this was a different issue, but you have indeed found a legit bug! Thank you!
Up till 20! factorial, the answer is correct. But starting 21!, the answers are incorrect by (-1)!. For example, if I calculate 22!, the answer I get is (22-1)!, or 21!
And the answer for 20! and 21! factorial is the same.