I am trying to make a program that can find all the wilson primes(i know it will be useless and wont get further than the first 3 known)
but it is still bugging be that the code returns nothing
using System;
namespace Wilson_Primes
{
class MainClass
{
public static void Main (string[] args)
{
int count = 1;
int basenumber = 0;
int final, i;
while (count > 0){
int prime = basenumber - 1;
for (i = prime - 1; i >= 1; i--)
{
final = prime * i;
Console.WriteLine (final);
}
count = count + 1;
}
}
}
}
VulpesPosted Oct 6, 2014, 1:58 PM
The only known ones are 5, 13 and 563.
To generate these, we therefore need to know whether a given number (from 2 to 599 say) is prime and what (p -1) factorial is.
Unfortunately, factorials exceed even the range of unsigned long integers well before this point is reached and we therefore need to resort to the System.Numerics.BigInteger struct, which was introduced in .NET 4.0 (VS 2010) and can handle integers of unlimited size, to obtain the final Wilson prime.
The following code does that:
/* add reference to System.Numerics.dll */
The output is: