Advertisement
Guest User

Fermat Is Prime broken

a guest
Feb 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. public static bool fermatIsPrime(int p)
  2.         {
  3.             Random randomGen = new Random();
  4.  
  5.             if (p == 1)
  6.             {
  7.                 return false;
  8.             }
  9.             else
  10.             {
  11.                 int a = 0;
  12.                 a = randomGen.Next(1, p);
  13.                 if (p % (a ^ (p - 1) - a) == 1)
  14.                 {
  15.                     return true;
  16.                 }
  17.                 else
  18.                 {
  19.                     return false;
  20.                 }
  21.             }
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement