Jake and Rpgfan,

Either of your solutions seem to work ok.

However, for some strange reason, if the input number "n" is greater than 2,147,483,647, which is the maximum value for a LONG integer, you will get an Error 06: overflow error, when the MOD instruction gets executed.

I consulted the QB Online Help plus my Quickbasic manual and there is no mention of any maximum values for the MOD operator. However, it does mention that "real" values will be rounded to integers, and this could be a clue as to why the maximum is a long integer.

So, the bottom line is that if your number is equal or greater than 2,147,483,647 then you can't use a MOD in your logic to determine if it's a prime number.

*****

Actually, there is an algorithim for figuring out modulo arithmetic for very large numbers, but I forgot it a long time ago.