Skip to main content
2 of 3
added 361 characters in body
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 63 59 bytes

.+ $* M`^(1+)¶(1+\1)(?<!¶\3+(\5\4*(?<=¶\4+)(1+(1+))))\2*$ 0 

Try it online! Takes line-separated input in the order B,n but test suite converts from comma-separated n,B for convenience. Explanation:

.+ $* 

Convert B and n to unary.

M`^(1+)¶(1+\1)(?<!¶\3+(\5\4*(?<=¶\4+)(1+(1+))))\2*$ 

Try to find (in $2) an integer that is greater than b, a power of a prime, and a factor of n. The expression for checking for the power of a prime is taken from @Deadcode's answer to Is it almost-prime? (but reversed naturally because this is a lookbehind). Note that the previous 63-byte version was faster because it checked for factors before prime powers: Try it online!

0 

Check that there wasn't a match.

Neil
  • 184.4k
  • 12
  • 76
  • 290