Advertisement
Guest User

PrimeNumbers

a guest
Feb 3rd, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. /************************************************************************
  2.  *  A business logic example                                            *
  3.  *  This class (this package, actually) is invoked by the GUI class.    *
  4.  *                                                                      *
  5.  ************************************************************************/
  6.  
  7. package BusinessLogicPackage;
  8.  
  9. import java.math.BigInteger;
  10.  
  11. import GUIPackage.MyForm;
  12.  
  13. public class PrimeNumbers{
  14.    
  15.     public static boolean BigIntisPrime(BigInteger b) {
  16.  
  17.         BigInteger i = new BigInteger("2");
  18.         while (i.compareTo(b) < 0){
  19.             BigInteger tmp = b.mod(i);
  20.             if(tmp.compareTo(BigInteger.ZERO) == 0) {
  21.                 //System.out.println("Factor Found: " + i.toString());
  22.                 return false;}
  23.             i = i.add(BigInteger.ONE);
  24.         }
  25.        
  26.         return true;   
  27.        
  28.     }  
  29.  
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement