Labdabeta 182 Posting Pro in Training Featured Poster

I have a difficult function to write and I have no idea where to begin. Here is the definition of what I need to write:
"A function f(x,y) which returns true if the binary number formed by concatenating the bits of x, 8*y-1 zeroes and a one is prime, false otherwise. x is an array of bytes (unsigned char) and y is an unsigned integer comprised of two bytes (unsigned short)."
EG:
f(10,1234)=isPrime(00001010...0x9871...1)
I am just completely lost as to what to do. I think there should be a better way than actually creating a class that can store massive numbers and than doing the traditional primality check of:

bool isPrime(myLargeIntegerMimic a)
{
    for (myLargeIntegerMimic i=2; i*i<a; i++)
    {
        if (a%i==0)
            return false;
    }
    return true;
}

Since myLargeIntegerMimic would have to store a massive array of 'y' bytes and then would have to successfully do multiplication and modulation on it, this would be extremely slow. I am hoping that I am missing some kind of short-cut.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.