APL(NARS) 41 chars, 82 bytes
{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
{π⍵} is the function factorization of argument ⍵ in the list of prime factors (repeat if one prime appear more time);
{1π⍵} is the function next prime (note that in this case its argument is not a scalar but one array of integers). test:
h←{(1=≢∪+/¨{v=⍵⊃v}¨⍳≢v)∧(1↓w)≡¯1↓1πw←∪v←π⍵}
(2..30)/⍨h¨2..30
2 3 4 5 6 7 8 9 11 13 15 16 17 19 23 25 27 29 30
h¨27000 456533 72 10000000
1 1 0 0