File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 33
44class DigitsOfE
55{
6+ private static readonly double LogOfTau = Math . Log ( Math . Tau ) ;
7+ private static readonly double LogOfTen = Math . Log ( 10 ) ;
8+
69 public static void Main ( string [ ] args )
710 {
811 int n ;
@@ -45,7 +48,7 @@ public static void Main(string[] args)
4548 {
4649 if ( b == a + 1 )
4750 {
48- return ( new BigInteger ( 1 ) , new BigInteger ( b ) ) ;
51+ return ( BigInteger . One , new BigInteger ( b ) ) ;
4952 }
5053 var mid = ( a + b ) / 2 ;
5154 var ( pLeft , qLeft ) = SumTerms ( a , mid ) ;
@@ -79,12 +82,12 @@ static int BinarySearch(int n)
7982
8083 static bool TestK ( int n , int k )
8184 {
82- if ( k < 0 )
85+ if ( k <= 0 )
8386 {
8487 return false ;
8588 }
86- var lnKFactorial = k * ( Math . Log ( ( double ) k ) - 1 ) + 0.5 * Math . Log ( Math . PI * 2 ) ;
87- var log10KFactorial = lnKFactorial / Math . Log ( 10 ) ;
89+ var lnKFactorial = k * ( Math . Log ( ( double ) k ) - 1 ) + 0.5 * LogOfTau ;
90+ var log10KFactorial = lnKFactorial / LogOfTen ;
8891 return log10KFactorial >= ( double ) ( n + 50 ) ;
8992 }
9093}
You can’t perform that action at this time.
0 commit comments