Skip to main content

Blum Integer

Blum Integer is the number which only haves 2 factors suppose p and q (i.e. n = p * q), both are Semi-prime and also they(p and q) are of the form 4t + 3, where t is some integer. First few Blum Integers are 21, 33, 57, 69, 77, 93, 129, 133, 141, 161, 177, … Note: Because of the condition that both the factors should be semi-primes, even numbers can not be Blum integers neither can be the numbers below 20, So we have to check only for an odd integer greater than 20 that if it is a Blum Integer or not.


function blum(n)
{
    var prime = seive();
    for(var i = 2; i <= n; i++)
    {
      if(prime[i] === 1)
      {
        if((n % i == 0) && ((i - 3) % 4) == 0)
        {
          var q = n / i;
          return (q != i && prime[q] === 1 && (q - 3) % 4 === 0);
        }
      }
    }

    return false;
}