It would help if you posted in some kind of pseudocode that doesn't require knowledge of specific UBasic (or whatever) syntax. Anyway, had you bothered to actually *analyze* your algorithm, you'd see that it amounts to taking a Mersenne number N = M(p), then raising the seed B=3 to some "magic" obfuscated power which (using that \ is UBasic for "integer divide") equals
pow = floor(N/2) * floor(N/3).
E.g. for M(p) with p=3 this works out to floor(7/2) * floor(7/3) = 3*2 = 6. For general odd p, it simply amounts to an obfuscated way or writing N1. Thus, this is nothing more than a base3 Fermat pseudoprime test.
May I politely suggest you actually read up on your basic number theory?
