using System;
public class Test
{
public static void Main()
{
int n = 600851475143;
int x = 1;
While (x<n)
{
if(n%x==0)
{
Console.WriteLine(x);
}
x++;
}
}
}
Gives me a { out of place error, but I can’t see whats wrong. Anyone?
Whileshould not be capitalized, and your value ofnis too large for an int.You don’t seem to have a problem with braces. If you fix those two errors it should compile.
Edit: The code file you posted is a completely different error than the one you posted in the question. A C# program can only have one entry point, which is what
public static void Main()does. If you copy and pasted the method signature from theProgramfile it is not going to compile. ChangeMainto any other valid signature and it should compile.