Skip to main content
deleted 478 characters in body
Source Link
lynn
  • 69.2k
  • 11
  • 133
  • 283

Haskell, 6153 bytes

f b=[x|x<-[b..],g<-[all$(<2).gcd x],g[bk<-1..b+1]>g[2[2..x-1]]1],mod x k+gcd(b^3-b)x<2]!!0

Try it online!

Searches for the smallest x, upward starting from b, satisfying this condition:

Define g(s) to check if x is coprime to all numbers in s.

Then demand: g([b-1,b,b+1]) and not g([2,3..x-1]).

(So x passes all the "divisibility rules", but it's not prime.)

It's okay to start the search from b instead of b+1, because the answer will never be x=b. (The guarantee that b>=2 means gcd(x,b) = gcd(b,b) = b > 1.)Try it online!

Haskell, 61 bytes

f b=[x|x<-[b..],g<-[all$(<2).gcd x],g[b-1..b+1]>g[2..x-1]]!!0

Try it online!

Searches for the smallest x, upward starting from b, satisfying this condition:

Define g(s) to check if x is coprime to all numbers in s.

Then demand: g([b-1,b,b+1]) and not g([2,3..x-1]).

(So x passes all the "divisibility rules", but it's not prime.)

It's okay to start the search from b instead of b+1, because the answer will never be x=b. (The guarantee that b>=2 means gcd(x,b) = gcd(b,b) = b > 1.)

Haskell, 53 bytes

f b=[x|x<-[b..],k<-[2..x-1],mod x k+gcd(b^3-b)x<2]!!0

Try it online!

Source Link
lynn
  • 69.2k
  • 11
  • 133
  • 283

Haskell, 61 bytes

f b=[x|x<-[b..],g<-[all$(<2).gcd x],g[b-1..b+1]>g[2..x-1]]!!0

Try it online!

Searches for the smallest x, upward starting from b, satisfying this condition:

Define g(s) to check if x is coprime to all numbers in s.

Then demand: g([b-1,b,b+1]) and not g([2,3..x-1]).

(So x passes all the "divisibility rules", but it's not prime.)

It's okay to start the search from b instead of b+1, because the answer will never be x=b. (The guarantee that b>=2 means gcd(x,b) = gcd(b,b) = b > 1.)