Русская версия The canonical variant checks by the division, but I decided to create all multiplication variants and then to enumerate numbers for which there is no such variant.
As usual, I've learned a lot...
template
struct K;
template struct K
{
void not_prim();
};
template struct K : public K
{
using K::not_prim;
K() { char a[J] = {0}; not_prim(a); }
};
template struct K : public K
{
using K::not_prim;
typedef const char A[J*I];
virtual void not_prim(const A &) const;
};
int main()
{
K<55> k;
}
Generated by GNU Source-highlight 2.9
In fact, this is an implementation of the Sieve of Eratosthenes.