Chris
2013-08-15 16:35:55 UTC
static void Main(string[] args)
{
int x = 1;
int z = 2;
int ar = 0;
string[] prime = new string[ar];
while (x <= 99)
{
z = 2;
while (z <= 9)
{
var y = (x/z);
Console.WriteLine(y);
if (y.GetType() == typeof(double))
{
prime[ar] = x.ToString();
ar ;
Console.WriteLine(x " is a prime!");
}
z ;
}
x ;
Console.WriteLine(x);
}
File.WriteAllLines(@"C:\users\chris\desktop\primeornot.txt", prime);
Console.ReadLine();
}
Fails to find a prime number? What this code does is check to see if the division came out as a whole number, or a decimal, and if it came out as a decimal, put it inside an array.