10001th prime: Difference between revisions

Content added Content deleted
Line 239: Line 239:


=={{header|C#|CSharp}}==
=={{header|C#|CSharp}}==
<lang csharp>using System; using System.Text; // PRIME russian DANILIN
<lang csharp>using System; using System.Text; // PRIME_numb.cs russian DANILIN
namespace p10001 // 1 second 10001 104743
namespace p10001 // 1 second 10001 104743
{ class Program // rextester.com/YXNR89875
{ class Program // rextester.com/ZBEPGE34760
{ static void Main(string[] args)
{ static void Main(string[] args)
{ int max=10001; int n=1; int p=1; int f; int j;
{ int max=10001; int n=1; int p=1; int f; int j; long s;
while (n <= max)
while (n <= max)
{ f=0; j=2;
{ f=0; j=2; s=Convert.ToInt32(Math.Pow(p,0.5));
while (f < 1)
while (f < 1)
{ if (j >= Convert.ToInt32(Math.Pow(p,0.5)))
{ if (j >= s)
{ f=2; }
{ f=2; }
if (p % j == 0) { f=1; }
if (p % j == 0) { f=1; }
Line 255: Line 255:
p++;
p++;
}
}
Console.Write("{0} {1}", n-1, p-1);
Console.Write("{0} {1}", n-1, p-1);
Console.ReadKey();
Console.ReadKey();
}}}</lang>
}}}</lang>
{{out}}
{{out}}