Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FINAL PRIME NUMBER GENERATOR IN C#
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { double prime = 0; double count = 6; double iterations = 8100; double i = 0; double j = 0; for (i=1; i<=double.PositiveInfinity; i++) { if (count == (iterations+1)){ Console.WriteLine($"Count has reached zero"); count -=1; break;} if (i%2!=0 && i%3!=0 && i%5!=0 && i%7!=0 && i%11!=0 && i!=1 && count>0) { for (j=13; j<=(i-1); j++) { if (i%j == 0) { //Console.WriteLine($"non prime"); goto i2; } } prime = i; //Console.WriteLine($"prime{count}, {prime}"); count+=1; } i2: if (count == (iterations+1)){ Console.WriteLine($"Count is zero...breaking loop"); } } Console.WriteLine($"prime number {count} is {prime}"); } } }
run
|
edit
|
history
|
help
0
Creating async methods in C# prior to version 5.0
C# Calculator Simple
OOP vs DOD
GetChange
Decimal separator diff
Lab8
hello,world
fracOp
Main3
ADCSXAA