From 941f3acc56c53af1ea2d87683564a4f912648f49 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 6 Dec 2022 01:18:10 +0000 Subject: [PATCH] [ci skip] Condense switch statement for IsPrime --- X10D/src/Math/Int64Extensions.cs | 7 +++---- X10D/src/Math/UInt64Extensions.cs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/X10D/src/Math/Int64Extensions.cs b/X10D/src/Math/Int64Extensions.cs index 51dfc75..01f10fa 100644 --- a/X10D/src/Math/Int64Extensions.cs +++ b/X10D/src/Math/Int64Extensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; namespace X10D.Math; @@ -117,9 +117,8 @@ public static class Int64Extensions { switch (value) { - case < 2: return false; - case 2: - case 3: return true; + case <= 1: return false; + case <= 3: return true; } if (value % 2 == 0 || value % 3 == 0) diff --git a/X10D/src/Math/UInt64Extensions.cs b/X10D/src/Math/UInt64Extensions.cs index d0f78bd..f081236 100644 --- a/X10D/src/Math/UInt64Extensions.cs +++ b/X10D/src/Math/UInt64Extensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; namespace X10D.Math; @@ -93,9 +93,8 @@ public static class UInt64Extensions { switch (value) { - case < 2: return false; - case 2: - case 3: return true; + case <= 1: return false; + case <= 3: return true; } if (value % 2 == 0 || value % 3 == 0)