コード例 #1
0
ファイル: BigInteger.cs プロジェクト: chaoscode/SteamSharp
		//***********************************************************************
		// Generates a positive BigInteger that is probably prime.
		// Overloaded to use the isProbablePrime method with no confidence value
		//***********************************************************************

		internal static BigInteger genPseudoPrime(int bits, Random rand)
		{
			BigInteger result = new BigInteger();
			bool done = false;

			while (!done)
			{
				result.genRandomBits(bits, rand);
				result.data[0] |= 0x01;		// make it odd

				// prime test
				done = result.isProbablePrime();
			}
			return result;
		}