mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-21 21:58:47 +00:00
refactor: fix logic for IBinaryInteger<T>.Factorial
The algorithm now starts at IBinaryInteger<T>.MultiplicativeIdentity rather than IBinaryInteger<T>.One
This commit is contained in:
parent
024f6dbd7a
commit
c7e78f5d19
@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Changed
|
||||
|
||||
- X1OD: `IBinaryInteger<T>.Factorial` now starts at `IBinaryInteger<T>.MultiplicativeIdentity` not
|
||||
`IBinaryInteger<T>.One`.
|
||||
- X10D: Removed `byte.Product`, `short.Product`, `ushort.Product`, `int.Product`, `uint.Product`, `long.Product`,
|
||||
and `ulong.Product`, in favour of `INumber<T>.Product`.
|
||||
- X10D: Removed `byte.RangeTo`, `short.RangeTo`, `ushort.RangeTo`, `int.RangeTo`, `uint.RangeTo`, `long.RangeTo`,
|
||||
|
@ -69,13 +69,13 @@ public static class BinaryIntegerExtensions
|
||||
return 1;
|
||||
}
|
||||
|
||||
var result = 1L;
|
||||
TInteger result = TInteger.MultiplicativeIdentity;
|
||||
for (TInteger i = TInteger.One; i <= value; i++)
|
||||
{
|
||||
result *= long.CreateChecked(i);
|
||||
result *= i;
|
||||
}
|
||||
|
||||
return result;
|
||||
return long.CreateChecked(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user