/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package logarithm;


/**
 *
 * @author jirka
 */
public class PrimeGen 
{
    
    private Integer Range;
    
    public PrimeGen(Integer iFrom, Integer iTo)
    { 
        Range = iTo-iFrom;
        if (Range <= 0) Range = 100;        
    }
    public Integer generateRandomPrime()
    {
        Integer prime = (int) Math.abs(Math.random()*Range);
        
        while (!isPrime(prime)) prime++;
        
        return prime;
    }
    
    static public boolean isPrime(Integer no)
    {   
        if (no < 1) return false;
        
        int testNo = 2;
        
        while (testNo < no)
        {
            if (no%testNo == 0) return false;
            testNo++;
        }
        
        return true;
    }
}
