Skip to main content
added 145 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 63 5959 58 bytes

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

Try it online!Try it online! Takes line-separated input in the order B,n,B but test suite converts from comma-separated n,B for convenience. Edit: Saved 1 byte thanks to a hint by @Deadcode. Explanation:

.+ $* 

Convert Bn and nB to unary.

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

Try to find (in $2$4) an integer that is greater than b, a power of a prime, and a factor of n. The r flag makes the expression for checkingmatch from the right, so $5 is matched to b first, then $4, then $4 is checked for the power of a prime is taken(taken from @Deadcode's answer to Is it almost-prime? (but reversed naturally because this, matching left-to-right as it is a lookbehindlookahead), then it is checked for a factor of n. Note that theThe 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.

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.

Retina 0.8.2, 63 59 58 bytes

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

Try it online! Takes line-separated input n,B but test suite converts from comma-separated for convenience. Edit: Saved 1 byte thanks to a hint by @Deadcode. Explanation:

.+ $* 

Convert n and B to unary.

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

Try to find (in $4) an integer that is greater than b, a power of a prime, and a factor of n. The r flag makes the expression match from the right, so $5 is matched to b first, then $4, then $4 is checked for the power of a prime (taken from @Deadcode's answer to Is it almost-prime?, matching left-to-right as it is a lookahead), then it is checked for a factor of n. 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.

added 361 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 6363 59 bytes

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

Try it online!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+))))\2*$ 

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

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.

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.

Source Link
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.