##C++ template metaprogramming. 166 131 119 bytes.
C++ template metaprogramming. 166 131 119 bytes.
Code compiles if the constant is a prime, and does not compile if composite or 1.
template<int a,int b=a>struct t{enum{x=t<a,~-b>::x+!(a%b)};};
template<int b>struct t<b,0>{enum{x};};
int _[t<1>::x==2];
(all newlines, except final one, are eliminated in "real" version).
I figure "failure to compile" is a falsey return value for a metaprogramming language. Note that it does not link (so if you feed it a prime, you'll get linking errors) as a full C++ program.
The value to test is the integer on the last "line".