CSharp examples for System:Math Number
Approximate Nth Prime
using System.Numerics; using System.Collections.Generic; using System.Collections; using System;//from w w w . j a va2 s . co m using EulersSolver.Extensions; public class Main{ public static int ApproximateNthPrime(int nn) { double n = (double)nn; double p; if (nn >= 7022) { p = n * Math.Log(n) + n * (Math.Log(Math.Log(n)) - 0.9385); } else if (nn >= 6) { p = n * Math.Log(n) + n * Math.Log(Math.Log(n)); } else if (nn > 0) { p = new int[] { 2, 3, 5, 7, 11 }[nn - 1]; } else { p = 0; } return (int)p; } }