1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 08:15:41 +00:00

[ci skip] Condense switch statement for IsPrime

This commit is contained in:
Oliver Booth 2022-12-06 01:18:10 +00:00
parent 9d6dbaaa23
commit 941f3acc56
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
2 changed files with 6 additions and 8 deletions

View File

@ -1,4 +1,4 @@
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace X10D.Math; namespace X10D.Math;
@ -117,9 +117,8 @@ public static class Int64Extensions
{ {
switch (value) switch (value)
{ {
case < 2: return false; case <= 1: return false;
case 2: case <= 3: return true;
case 3: return true;
} }
if (value % 2 == 0 || value % 3 == 0) if (value % 2 == 0 || value % 3 == 0)

View File

@ -1,4 +1,4 @@
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace X10D.Math; namespace X10D.Math;
@ -93,9 +93,8 @@ public static class UInt64Extensions
{ {
switch (value) switch (value)
{ {
case < 2: return false; case <= 1: return false;
case 2: case <= 3: return true;
case 3: return true;
} }
if (value % 2 == 0 || value % 3 == 0) if (value % 2 == 0 || value % 3 == 0)