1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-24 14:58:49 +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:
Oliver Booth 2024-11-14 16:06:52 +00:00
parent 024f6dbd7a
commit c7e78f5d19
Signed by: oliverbooth
GPG Key ID: 2A862C3F46178E8E
2 changed files with 5 additions and 3 deletions

View File

@ -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`,

View File

@ -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>