Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions bench/algorithm/edigits/1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

class DigitsOfE
{
private static readonly double LogOfTau = Math.Log(Math.Tau);
private static readonly double LogOfTen = Math.Log(10);

public static void Main(string[] args)
{
int n;
Expand Down Expand Up @@ -45,7 +48,7 @@ public static void Main(string[] args)
{
if (b == a + 1)
{
return (new BigInteger(1), new BigInteger(b));
return (BigInteger.One, new BigInteger(b));
}
var mid = (a + b) / 2;
var (pLeft, qLeft) = SumTerms(a, mid);
Expand Down Expand Up @@ -79,12 +82,12 @@ static int BinarySearch(int n)

static bool TestK(int n, int k)
{
if (k < 0)
if (k <= 0)
{
return false;
}
var lnKFactorial = k * (Math.Log((double)k) - 1) + 0.5 * Math.Log(Math.PI * 2);
var log10KFactorial = lnKFactorial / Math.Log(10);
var lnKFactorial = k * (Math.Log((double)k) - 1) + 0.5 * LogOfTau;
var log10KFactorial = lnKFactorial / LogOfTen;
return log10KFactorial >= (double)(n + 50);
}
}
Loading