Skip to main content
improved version much faster algorithm and saves 7 bytes
Source Link
jayprich
  • 421
  • 2
  • 8

J, 5454 47 bytes

-:@+/@:*:@((1+]*/:~)`]@.((1=+./)*(=<@,.)@%&1@x:@((]*]^/)-@([*[)))^:_>2&p:)^:(<8<12)3

plain vanilla implementation : starting at x set y=x+1 >: and iterate (1+]) incrementing y until both predicates (1=+.) "hcf is 1" and (=<.)@%:@((]*])-([*[)))^:_>: "differenceTIO

greedy split of squares is a perfect square" are satisfiedprime factors into coprime factors

TIOold 54 bytes TIO

J, 54 bytes

((1+])`]@.((1=+.)*(=<.)@%:@((]*])-([*[)))^:_>:)^:(<8)3

plain vanilla implementation : starting at x set y=x+1 >: and iterate (1+]) incrementing y until both predicates (1=+.) "hcf is 1" and (=<.)@%:@((]*])-([*[)))^:_>: "difference of squares is a perfect square" are satisfied

TIO

J, 54 47 bytes

-:@+/@:*:@((*/:~)/)@,.&1@x:@(^/)@(2&p:)^:(<12)3

TIO

greedy split of prime factors into coprime factors

old 54 bytes TIO

Source Link
jayprich
  • 421
  • 2
  • 8

J, 54 bytes

((1+])`]@.((1=+.)*(=<.)@%:@((]*])-([*[)))^:_>:)^:(<8)3

plain vanilla implementation : starting at x set y=x+1 >: and iterate (1+]) incrementing y until both predicates (1=+.) "hcf is 1" and (=<.)@%:@((]*])-([*[)))^:_>: "difference of squares is a perfect square" are satisfied

TIO