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 =100; double i = 0; double j = 0; for (i=1; i<=double.PositiveInfinity; i++) { if (count == iterations){ Console.WriteLine($"Count has reached zero, Product is {prime}"); 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){ Console.WriteLine($"Count is zero...breaking loop"); break;} } Console.WriteLine($"the final count is {count}"); } } }
run
|
edit
|
history
|
help
0
PYRAMIDPATTERN
Main4-4
Boggle
Encryption Practice
Heap sort
Roman Numbers, Sorting through IComparer
asdfrgthyu6543wdsc
1234
AdventCode
InvokeProgram