Skip to main content
1 of 3
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 63 bytes

.+ $* M`^(1+)¶(1+\1)(?=\2*$)(?<!¶\3+(\5\4*(?<=¶\4+)(1+(1+)))) 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)(?=\2*$)(?<!¶\3+(\5\4*(?<=¶\4+)(1+(1+)))) 

Try to find (in $2) an integer factor of n greater than b that is a power of a prime. 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).

0 

Check that there wasn't a match.

Neil
  • 184.4k
  • 12
  • 76
  • 290